public RadForm1() { InitializeComponent(); BindingList <Item> items = new BindingList <Item>(); for (int i = 0; i < 5; i++) { items.Add(new Item(i, "Item" + i)); } this.radGridView1.DataSource = items; this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; //register the custom row behavior BaseGridBehavior gridBehavior = this.radGridView1.GridBehavior as BaseGridBehavior; gridBehavior.UnregisterBehavior(typeof(GridViewDataRowInfo)); gridBehavior.RegisterBehavior(typeof(GridViewDataRowInfo), new CustomGridDataRowBehavior()); //handle drag and drop events for the grid through the DragDrop service RadDragDropService svc = this.radGridView1.GridViewElement.GetService <RadDragDropService>(); svc.PreviewDragStart += svc_PreviewDragStart; svc.PreviewDragDrop += svc_PreviewDragDrop; svc.PreviewDragOver += svc_PreviewDragOver; }
protected override void OnPanGesture(PanGestureEventArgs args) { base.OnPanGesture(args); RadDragDropService columnDragDropService = (RadDragDropService)(this.Data.Owner.ViewElement as DetailListViewElement).ColumnDragDropService; if (columnDragDropService.State != RadServiceState.Working && this.IsInResizeLocation(args.Location)) { return; } if (args.IsBegin) { int num = (int)this.SetValue(RadElement.IsMouseDownProperty, (object)true); columnDragDropService.BeginDrag(this.ElementTree.Control.PointToScreen(args.Location), (ISupportDrag)this); } if (columnDragDropService.State == RadServiceState.Working) { columnDragDropService.DoMouseMove(this.ElementTree.Control.PointToScreen(args.Location)); } if (args.IsEnd) { columnDragDropService.EndDrag(); int num1 = (int)this.SetValue(RadElement.IsMouseDownProperty, (object)false); int num2 = (int)this.ResetValue(RadElement.IsMouseDownProperty, ValueResetFlags.Local); } args.Handled = true; }
private void SetPreferences() { this.SetEnabledQsfbButton(QSFButtons.TransparentBackground | QSFButtons.ChangeTheme, false); RadDragDropService service = this.radPageView1.ViewElement.ItemDragService; service.Starting += ItemDragService_Starting; service.Started += ItemDragService_Started; service.Stopping += ItemDragService_Stopping; service.Stopped += ItemDragService_Stopped; service.PreviewDropTarget += ItemDragService_PreviewDropTarget; this.textBox1.ReadOnly = true; this.radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; this.radGridView2.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; this.radGridView3.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; this.productsTableAdapter.Fill(this.northwindDataSet.Products); this.employeesTableAdapter.Fill(this.northwindDataSet.Employees); this.ordersTableAdapter.Fill(this.northwindDataSet.Orders); this.radGridView1.Columns["UnitPrice"].FormatString = "${0}"; this.radGridView1.Columns["UnitPrice"].TextAlignment = ContentAlignment.MiddleRight; this.radGridView2.TableElement.RowHeight += 5; this.radGridView3.Columns["OrderID"].TextAlignment = ContentAlignment.MiddleRight; foreach (PageViewItemDragMode mode in Enum.GetValues(typeof(PageViewItemDragMode))) { RadListDataItem item = new RadListDataItem(mode.ToString()); this.dragModeCombo.Items.Add(item); } this.dragModeCombo.SelectedIndex = 0; }
public Form1() { InitializeComponent(); Random rand = new Random(); List <MyObject> list = new List <MyObject>() { }; for (int i = 0; i < 10; i++) { list.Add(new MyObject(rand.Next(0, 4), "Name " + i, images[rand.Next(0, images.Count)])); } radGridView1.DataSource = list; radGridView1.AutoSizeRows = true; radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; //populate the grid with data RadDragDropService svc = this.radGridView1.GridViewElement.GetService <RadDragDropService>(); svc.PreviewDragStart += svc_PreviewDragStart; svc.PreviewDragOver += svc_PreviewDragOver; radGridView1.GroupByChanged += radGridView1_GroupByChanged; radGridView1.EnableCustomGrouping = true; radGridView1.CustomGrouping += radGridView1_CustomGrouping; radGridView1.GroupSummaryEvaluate += radGridView1_GroupSummaryEvaluate; }
public Form1() { InitializeComponent(); //populate with data GridViewTextBoxColumn col = new GridViewTextBoxColumn("col"); col.Width = 200; radGridView1.Columns.Add(col); for (int i = 0; i < 10; i++) { radGridView1.Rows.Add("Row " + i); radTreeView1.Nodes.Add("Node " + i); } //register the custom row behavior BaseGridBehavior gridBehavior = this.radGridView1.GridBehavior as BaseGridBehavior; gridBehavior.UnregisterBehavior(typeof(GridViewDataRowInfo)); gridBehavior.RegisterBehavior(typeof(GridViewDataRowInfo), new CustomGridDataRowBehavior()); RadDragDropService dragDropService = radGridView1.GridViewElement.GetService <RadDragDropService>(); dragDropService.PreviewDragStart += dragDropService_PreviewDragStart; dragDropService.PreviewDragOver += dragDropService_PreviewDragOver; dragDropService.PreviewDragDrop += dragDropService_PreviewDragDrop; dragDropService.PreviewDragHint += dragDropService_PreviewDragHint; dragDropService.Stopped += dragDropService_Stopped; }
protected override void OnPanGesture(PanGestureEventArgs args) { base.OnPanGesture(args); RadPanoramaElement tilePanelElement = this.FindTilePanelElement(); if (tilePanelElement == null || !this.AllowDrag) { return; } RadDragDropService dragDropService = tilePanelElement.DragDropService; if (args.IsBegin) { this.currentPanOffset = SizeF.Empty; this.panBeginLocation = this.ElementTree.Control.PointToScreen(args.Location); this.ZIndex = 1000; } if (dragDropService.State == RadServiceState.Working) { dragDropService.DoMouseMove(this.ElementTree.Control.PointToScreen(args.Location)); } else { tilePanelElement.ScrollView(args.Offset.Width, true); if (tilePanelElement.AllowDragDrop) { if (!args.IsInertia) { this.currentPanOffset.Width += (float)args.Offset.Width; this.currentPanOffset.Height += (float)args.Offset.Height; } if ((double)Math.Abs(this.currentPanOffset.Height) > (double)(this.Size.Height / this.RowSpan)) { this.PositionOffset = SizeF.Empty; this.panBeginLocation.X += (int)this.currentPanOffset.Width; dragDropService.BeginDrag(this.panBeginLocation, (ISupportDrag)this); if (dragDropService.State == RadServiceState.Working) { dragDropService.DoMouseMove(this.ElementTree.Control.PointToScreen(args.Location)); } } else { this.PositionOffset = new SizeF(0.0f, 20f * this.currentPanOffset.Height / (float)(this.Size.Height / this.RowSpan)); } } } if (args.IsEnd) { if (dragDropService.State == RadServiceState.Working) { dragDropService.EndDrag(); } this.PositionOffset = SizeF.Empty; int num = (int)this.ResetValue(RadElement.ZIndexProperty, ValueResetFlags.Local); } args.Handled = true; }
private void ItemDragService_PreviewDropTarget(object sender, PreviewDropTargetEventArgs e) { RadDragDropService service = sender as RadDragDropService; RadPageViewItem item = e.DropTarget as RadPageViewItem; if (item != null) { ShowEventMessage(item.Text, "ItemDragService.PreviewDropTarget"); } }
private void SubscribeForGridEvents(RadGridView grid) { RadDragDropService dragDropService = grid.GridViewElement.GetService <RadDragDropService>(); dragDropService.PreviewDragOver += new EventHandler <RadDragOverEventArgs>(dragDropService_PreviewDragOver); dragDropService.PreviewDragDrop += new EventHandler <RadDropEventArgs>(dragDropService_PreviewDragDrop); dragDropService.PreviewDragHint += new EventHandler <PreviewDragHintEventArgs>(dragDropService_PreviewDragHint); grid.CellFormatting += new CellFormattingEventHandler(grid_CellFormatting); grid.Rows.CollectionChanged += new Telerik.WinControls.Data.NotifyCollectionChangedEventHandler(Rows_CollectionChanged); }
public override bool OnMouseDown(MouseEventArgs e) { this.disableSortOrderChange = false; bool flag = true; if (this.GridViewElement.IsInEditMode) { flag = this.GridViewElement.EndEdit(); } if (e.Button == MouseButtons.Left) { this.FindCellToResize(e.Location); if (this.columnToResize != null) { this.mouseIsDown = true; this.mouseDownPoint = e.Location; this.GridControl.Capture = true; this.RootGridBehavior.LockBehavior((IGridBehavior)this); this.cellToResize = this.GridViewElement.ElementTree.GetElementAtPoint(e.Location) as GridCellElement; this.mouseDownCell = this.cellToResize; } else { if (!flag) { return(true); } GridHeaderCellElement cellAtPoint = this.RootGridBehavior.CellAtPoint as GridHeaderCellElement; if (GridVisualElement.GetElementAtPoint <RadButtonElement>((RadElementTree)this.GridViewElement.ElementTree, e.Location) != null) { return(false); } this.mouseDownCell = (GridCellElement)cellAtPoint; if (cellAtPoint == null || this.GetVisibleColumnsCount(cellAtPoint) < 2) { return(false); } RadDragDropService service = this.GridViewElement.GetService <RadDragDropService>(); if (service != null) { service.Start((object)new SnapshotDragItem((RadItem)cellAtPoint)); service.Stopped += new EventHandler(this.dragDropService_Stopped); this.dragDropStarted = service.State == RadServiceState.Working; } } } else if (e.Button == MouseButtons.Right) { this.RootGridBehavior.CellAtPoint?.ShowContextMenu(); } return(false); }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); Debug.Assert(this.owner != null, "Must have an owning UI at this point."); if (this.Capture && e.Button == this.owner.ActionMouseButton && this.ControlBoundingRectangle.Contains(e.Location) && RadDragDropService.ShouldBeginDrag(e.Location, this.dragStart)) { this.owner.OnItemDrag(this, e); } }
protected override void InitializeFields() { base.InitializeFields(); this.itemDragService = new RadPageViewDragDropService(this); this.items = new RadPageViewReadonlyCollection <RadPageViewItem>(); this.actionMouseButton = MouseButtons.Left; this.itemListMenu = new RadContextMenu(); this.itemListMenu.DropDownClosed += OnItemListMenu_DropDownClosed; this.StretchHorizontally = true; this.StretchVertically = true; this.AllowDrop = true; this.UpdateSelectedItemContent = true; }
public DragAndDropRadGrid() { this.MultiSelect = true; //handle drag and drop events for the grid through the DragDrop service RadDragDropService svc = this.GridViewElement.GetService <RadDragDropService>(); svc.PreviewDragStart += svc_PreviewDragStart; svc.PreviewDragDrop += svc_PreviewDragDrop; svc.PreviewDragOver += svc_PreviewDragOver; //register the custom row selection behavior var gridBehavior = this.GridBehavior as BaseGridBehavior; gridBehavior.UnregisterBehavior(typeof(GridViewDataRowInfo)); gridBehavior.RegisterBehavior(typeof(GridViewDataRowInfo), new RowSelectionGridBehavior()); }
protected override void OnPanGesture(PanGestureEventArgs args) { base.OnPanGesture(args); RadDragDropService service = this.TemplateElement.GroupPanelElement.GetService <RadDragDropService>(); if (args.IsBegin && service.State != RadServiceState.Working) { service.BeginDrag(this.ElementTree.Control.PointToScreen(args.Location), (ISupportDrag)this); } if (service.State == RadServiceState.Working) { service.DoMouseMove(this.ElementTree.Control.PointToScreen(args.Location)); } if (args.IsEnd) { service.EndDrag(); } args.Handled = true; }
protected override void CreateChildElements() { base.CreateChildElements(); this.scrollBar = new RadScrollBarElement(); this.scrollBar.ZIndex = 1000; this.scrollBar.ScrollType = ScrollType.Horizontal; this.scrollBar.ValueChanged += new EventHandler(this.scrollBar_ValueChanged); this.Children.Add((RadElement)this.scrollBar); this.itemsLayout = new GridLayout(); this.itemsLayout.StretchHorizontally = this.itemsLayout.StretchVertically = true; this.itemsLayout.RadPropertyChanged += new RadPropertyChangedEventHandler(this.layout_RadPropertyChanged); this.Children.Add((RadElement)this.itemsLayout); this.groupsLayout = new StackLayoutPanel(); this.groupsLayout.RadPropertyChanged += new RadPropertyChangedEventHandler(this.layout_RadPropertyChanged); this.backgroundImage = new ImagePrimitive(); this.backgroundImage.Class = "PanoramaBackgroundImage"; this.backgroundImage.ZIndex = -5; this.backgroundImage.ImageLayout = ImageLayout.Stretch; this.backgroundImage.StretchHorizontally = this.backgroundImage.StretchVertically = true; this.Children.Add((RadElement)this.backgroundImage); this.items = new RadItemOwnerCollection(); this.items.ItemsChanged += new ItemChangedDelegate(this.items_ItemsChanged); this.items.ItemTypes = new System.Type[2] { typeof(RadTileElement), typeof(RadLiveTileElement) }; this.items.Owner = (RadElement)this.itemsLayout; this.groups = new RadItemOwnerCollection(); this.groups.ItemTypes = new System.Type[1] { typeof(TileGroupElement) }; this.groups.Owner = (RadElement)this.groupsLayout; this.dragDropService = (RadDragDropService) new TileDragDropService(this); this.scrollService = new ScrollService((RadElement)this, this.scrollBar); this.scrollService.EnableInertia = true; this.AllowDrop = true; }
protected override void OnPanGesture(PanGestureEventArgs args) { base.OnPanGesture(args); RadDragDropService service = this.serviceProvider.GetService <RadDragDropService>(); if (args.IsBegin) { int num = (int)this.SetValue(RadElement.IsMouseDownProperty, (object)true); service.BeginDrag(this.ElementTree.Control.PointToScreen(args.Location), (ISupportDrag)this); } if (service.State == RadServiceState.Working) { service.DoMouseMove(this.ElementTree.Control.PointToScreen(args.Location)); } if (args.IsEnd) { service.EndDrag(); int num1 = (int)this.SetValue(RadElement.IsMouseDownProperty, (object)false); int num2 = (int)this.ResetValue(RadElement.IsMouseDownProperty, ValueResetFlags.Local); } args.Handled = true; }
private void ItemDragService_Stopped(object sender, EventArgs e) { RadDragDropService service = sender as RadDragDropService; ShowEventMessage(string.Empty, "ItemDragService.Stopped"); }
private void ItemDragService_Starting(object sender, RadServiceStartingEventArgs e) { RadDragDropService service = sender as RadDragDropService; ShowEventMessage((e.Context as RadPageViewItem).Text, "ItemDragService.Starting"); }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (!this.Capture || e.Button != this.owner.ActionMouseButton || (!this.ControlBoundingRectangle.Contains(e.Location) || !RadDragDropService.ShouldBeginDrag(e.Location, this.dragStart))) { return; } this.owner.OnItemDrag(this, e); }