PC Review


Reply
Thread Tools Rate Thread

Can't combobox properly placed over datagrid cell

 
 
Terry Olsen
Guest
Posts: n/a
 
      23rd Nov 2004

Here's my code:

Private Sub dgServerList_CurrentCellChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles dgServerList.CurrentCellChanged
If dgServerList.CurrentCell.ColumnNumber = 2 Then
Dim cellRect As Rectangle =
dgServerList.GetCurrentCellBounds()
cboMailList.SetBounds(cellRect.X, cellRect.Y,
cellRect.Width, cellRect.Height)
cboMailList.Show()
Else
cboMailList.Hide()
End If
End Sub

Problem: The combobox shows up above & left of the cell it should be
covering. Can anyone help? Thanks!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
 
Chris, Lord of all Things Insignificant
Guest
Posts: n/a
 
      23rd Nov 2004
I could be wrong, I don't have a way to check right now, but doesn't the
GetCurrentCellBounds() return the coords in relation to the Datagrid. So
you would have to compensate for the offset of the datagrid. Just my
thought.

Chris


"Terry Olsen" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>
> Here's my code:
>
> Private Sub dgServerList_CurrentCellChanged(ByVal sender As Object,
> ByVal e As System.EventArgs) Handles dgServerList.CurrentCellChanged
> If dgServerList.CurrentCell.ColumnNumber = 2 Then
> Dim cellRect As Rectangle =
> dgServerList.GetCurrentCellBounds()
> cboMailList.SetBounds(cellRect.X, cellRect.Y,
> cellRect.Width, cellRect.Height)
> cboMailList.Show()
> Else
> cboMailList.Hide()
> End If
> End Sub
>
> Problem: The combobox shows up above & left of the cell it should be
> covering. Can anyone help? Thanks!
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
Terry Olsen
Guest
Posts: n/a
 
      23rd Nov 2004
I figured it out...but ran into another problem...here's the code:

Private Sub RepaintComboBox()
Dim dg As Rectangle = dgServerList.GetCurrentCellBounds
Dim cb As Rectangle =
Me.RectangleToClient(dgServerList.RectangleToScreen(dg))
cboMailList.SetBounds(cb.X, cb.Y, cb.Width, cb.Height)
cboMailList.Show()
cboMailList.BringToFront()
End Sub

I added a call to this Sub in the DataGrid_Scroll event. But now when
the row that the combobox is in scrolls out of view, the ComboBox
continues to be painted over the rest of the form as if the row was
still visible. I can't seem to find a way to tell if a row in a
datagrid is visible or not. Can anyone help with this? Thanks!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
Richard Myers
Guest
Posts: n/a
 
      25th Nov 2004
I can't seem to find a way to tell if a row in a
> datagrid is visible or not. Can anyone help with this? Thanks!


Hi Terry

Yep. Thats a bit of a curly one because it is not immediately obvious which event to register for
and that you can override the GridVScrolled method. However thats the event you want (assuming your
overriding the datagrid of course). NewValue property will give you the current verticsl value of
the scroll bar so you can do some basic arithmetic re: vert pos / row height = row etc.

It will also tell you the type of scroll event LargeInc/Small inc which could be helpful if you want
to decide whether there is any point in bothering to do a draw.
Note also that when setting the new value position this will only set the scroll position;it will
not update CurrentRow so you have to do another calc to sync these manually.

Protected Overrides Sub GridVScrolled(ByVal sender As Object, ByVal se As ScrollEventArgs)
Debug.WriteLine(se.NewValue)
Debug.WriteLine(se.Type.ToString())
End Sub

hth
Richard


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populating a combobox from dataset/datagrid cell value =?Utf-8?B?Um9iZXJ0?= Microsoft C# .NET 2 2nd Aug 2005 05:04 AM
ComboBox in DataGrid Cell, bombs when changing rows with arrow keys Charlie@CBFC Microsoft Dot NET Framework Forms 2 11th May 2005 12:39 PM
How do I get a datagrid to register a data change from a custom control cell (combobox)? =?Utf-8?B?bWV0YW1lZGlh?= Microsoft Dot NET Framework Forms 0 7th May 2004 11:31 PM
How do I get a datagrid to register a data change from a custom control cell (combobox)? =?Utf-8?B?bWV0YW1lZGlh?= Microsoft C# .NET 0 7th May 2004 11:31 PM
Adding a combobox in a datagrid cell Niccolo Microsoft C# .NET 2 17th Feb 2004 09:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:03 PM.