Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
6425 | Aug 12,2003 05:29 PM UTC | Aug 12,2003 05:48 PM UTC | WinForms | 1 |
![]() |
Tags: GridControl |
//in formload, subscribe to the events this.gridDataBoundGrid1.MouseDown += new MouseEventHandler(grid_MouseDown); this.gridDataBoundGrid1.MouseMove += new MouseEventHandler(grid_MouseMove); this.gridDataBoundGrid1.MouseUp += new MouseEventHandler(grid_MouseUp); //the handlers private Point mouseDownPoint = Point.Empty; private int mouseDownRow = -1; private int mouseDownCol = -1; private void grid_MouseDown(object sender, MouseEventArgs e) { Point pt = new Point(e.X, e.Y); int rowIndex, colIndex; if(this.gridDataBoundGrid1.PointToRowCol(pt, out rowIndex, out colIndex, -1)) { //check for photo column mousedown if(this.gridDataBoundGrid1[0, colIndex].Text == "Photo" && rowIndex > 0) { mouseDownPoint = new Point(e.X, e.Y); mouseDownRow = rowIndex; mouseDownCol = colIndex; } else { mouseDownPoint = Point.Empty; mouseDownRow = -1; mouseDownCol = -1; } } } private void grid_MouseMove(object sender, MouseEventArgs e) { //check if dragging... if(mouseDownPoint != Point.Empty) { if(Math.Abs(mouseDownPoint.X - e.X) + Math.Abs(mouseDownPoint.Y - e.Y) > 8) { //get the bitmap however??? Byte[] pict = this.gridDataBoundGrid1[mouseDownRow, mouseDownCol].CellValue as Byte[]; if(pict != null) { int PictOffSet = 78; MemoryStream buffer = new MemoryStream(pict, PictOffSet, pict.Length - PictOffSet); Bitmap image = (Bitmap)Bitmap.FromStream(buffer, true); this.DoDragDrop(image, DragDropEffects.All); } mouseDownPoint = Point.Empty; mouseDownRow = -1; mouseDownCol = -1; } } } private void grid_MouseUp(object sender, MouseEventArgs e) { mouseDownPoint = Point.Empty; mouseDownRow = -1; mouseDownCol = -1; }
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.