Results 1 to 7 of 7

Thread: DataGridViewCell Cursor and Border

  1. #1

    Thread Starter
    Fanatic Member clarkgriswald's Avatar
    Join Date
    Feb 2000
    Location
    USA
    Posts
    741

    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)

    Name:  trash.png
Views: 206
Size:  1.3 KB

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    5,818

    Re: DataGridViewCell Cursor and Border

    I would not have been using the CellMouseMove.
    I would have been using the CellMouseEnter and CellMouseLeave accordingly.
    .

  3. #3

    Thread Starter
    Fanatic Member clarkgriswald's Avatar
    Join Date
    Feb 2000
    Location
    USA
    Posts
    741

    Re: DataGridViewCell Cursor and Border

    Quote Originally Posted by sapator View Post
    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.

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,736

    Re: DataGridViewCell Cursor and Border

    Try the MouseEnter and the MouseLeave events of the editingcontrol exposed by the cell

  5. #5

    Thread Starter
    Fanatic Member clarkgriswald's Avatar
    Join Date
    Feb 2000
    Location
    USA
    Posts
    741

    Re: DataGridViewCell Cursor and Border

    Quote Originally Posted by .paul. View Post
    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

  6. #6

    Thread Starter
    Fanatic Member clarkgriswald's Avatar
    Join Date
    Feb 2000
    Location
    USA
    Posts
    741

    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...

  7. #7

    Thread Starter
    Fanatic Member clarkgriswald's Avatar
    Join Date
    Feb 2000
    Location
    USA
    Posts
    741

    Re: DataGridViewCell Cursor and Border

    This fixed the issue. Now the cell clipping issue is the only one left.

    VB.NET Code:
    1. Protected Overrides Sub WndProc(ByRef m As Message)
    2.  
    3.         Const WM_SETCURSOR = &H20
    4.  
    5.         If m.Msg = WM_SETCURSOR Then
    6.             Cursor.Current = Cursors.Arrow
    7.             m.Result = CType(1, IntPtr)
    8.             Return
    9.         End If
    10.  
    11.         MyBase.WndProc(m)
    12.  
    13.     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
  •  



Click Here to Expand Forum to Full Width