-
Jan 22nd, 2021, 10:55 AM
#1
Thread Starter
Fanatic Member
DataGridViewCell Cursor and Border
I have a custom DataGridViewCell that inherits a ComboBox. The custom cell supports selecting multiple items and thus the ComboBox DropDownStyle is DropDown. I prevent the user from being able to edit the text portion of the ComboBox, so I want to set the cursor to Arrow (similar to the way it would be if DropDownStyle = DropDownList). I can achieve this by updating the cursor in the CellMouseMove event, but the cursor flickers between arrow and Ibeam. I tried setting the cursor in the custom class and on e.control of the EditControlShowing event, but that has no affect. Any ideas on how to set the cursor to arrow for the cell or at worst, eliminate the flicker when setting via the CellMouseMove.
Also, any idea how to position the control so it is not clipped or is aligned with native combo cells? If I autosize rows, it is clipped, if I increase default row size by ONE pixel, it is not clipped, but the native combo cells look a bit odd (and even my custom cell looks to be aligned top as opposed to middle). I am a bit anal, so this drives me nuts ;o)
-
Jan 22nd, 2021, 05:43 PM
#2
Re: DataGridViewCell Cursor and Border
I would not have been using the CellMouseMove.
I would have been using the CellMouseEnter and CellMouseLeave accordingly.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Jan 22nd, 2021, 06:05 PM
#3
Thread Starter
Fanatic Member
Re: DataGridViewCell Cursor and Border
Originally Posted by sapator
I would not have been using the CellMouseMove.
I would have been using the CellMouseEnter and CellMouseLeave accordingly.
That’s actually what I tried at first as well, but did not work at all actually.
-
Jan 23rd, 2021, 01:40 AM
#4
Re: DataGridViewCell Cursor and Border
Try the MouseEnter and the MouseLeave events of the editingcontrol exposed by the cell
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jan 23rd, 2021, 08:48 AM
#5
Thread Starter
Fanatic Member
Re: DataGridViewCell Cursor and Border
Originally Posted by .paul.
Try the MouseEnter and the MouseLeave events of the editingcontrol exposed by the cell
Tried that as well; I think I need to intercept the messages for cursors:
https://stackoverflow.com/questions/...-arrow-cursors
-
Jan 23rd, 2021, 10:24 AM
#6
Thread Starter
Fanatic Member
Re: DataGridViewCell Cursor and Border
I can't seem to get the above link's suggestion to work either. This has to be possible to do...
-
Jan 23rd, 2021, 12:27 PM
#7
Thread Starter
Fanatic Member
Re: DataGridViewCell Cursor and Border
This fixed the issue. Now the cell clipping issue is the only one left.
VB.NET Code:
Protected Overrides Sub WndProc(ByRef m As Message)
Const WM_SETCURSOR = &H20
If m.Msg = WM_SETCURSOR Then
Cursor.Current = Cursors.Arrow
m.Result = CType(1, IntPtr)
Return
End If
MyBase.WndProc(m)
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|