During a drag and drop operation involving two DataGridViews, as source and targets, I need to display a custom string (either as a bitmap or simply text) ALONGSIDE (or at) the mouse pointer. I know how to replace the default cursor with a custom text, but this replace the pointer. I need to show both the pointer as well as the text (Similar to the cursor in Windows explorer when you drag n drop a file: you will notice theres a file name in addition to the mouse pointer). Thanks.
I am doing the below to replace the cusror with my custom string, but this replaces the pointer.
I am doing the below to replace the cusror with my custom string, but this replaces the pointer.
Code:
private void SetCustomCursor(string limitPrice) { SizeF size; Font f = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold); using (Bitmap tmpBmp = new Bitmap(1, 1)) using (Graphics g = Graphics.FromImage(tmpBmp)) size = g.MeasureString(limitPrice, f); Bitmap bitmap = new Bitmap((int)Math.Ceiling(size.Width), (int)Math.Ceiling(size.Height)); using (Graphics g = Graphics.FromImage(bitmap)) g.DrawString(limitPrice, f, Brushes.DarkOrange, 0, 0); Cursor.Current = CreateCursor(bitmap, 10, 10); //Cursor.Current = Cursors.Arrow; bitmap.Dispose(); f.Dispose(); } }
Comment