473,396 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Can't combobox properly placed over datagrid cell


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!
Nov 21 '05 #1
3 829
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" <to******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...

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!

Nov 21 '05 #2
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.RectangleToScree n(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!
Nov 21 '05 #3
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
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: MarkDu | last post by:
I want to have a datagrid, say 10 rows, and in one of the columns I want 7 of the rows to have plain text, and the other 3 rows to have a combobox (or linkbutton, etc). Is this even possible? I...
3
by: Bill C. | last post by:
Hello, I know this has been discussed a lot already because I've been searching around for information the last few weeks. I'm trying to implement a DataGridComboBoxColumn class. I've found...
3
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article:...
4
by: Martin Williams | last post by:
I have inserted a combobox into a datagrid cell. I am having difficulty getting the cell to retain the combobox selection. When I leave the cell, it remains empty. Here is the code, based on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.