Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid and Listbox Location

Status
Not open for further replies.

Hawkster

Programmer
Nov 12, 2001
10
GB
I have a datagrid and have a button set in one of the columns. I assume I have to add a listbox to my form and populate it with the data I want. No problem there.

My problem is this. How do I determine the location at which to show the listbox ?? as this will change depending on which row the button is clicked.
 
Here is what I did- I just set the combo box properties to match the cell properties in regard to top, left and width.

Code:
Private Sub dgMain_ButtonClick(ByVal ColIndex As Integer) 'click on the button in the cell

cmbMenu.Top = dgMain.RowTop(dgMain.Row)
cmbMenu.Left = dgMain.Columns(ColIndex).Left
cmbMenu.Width = dgMain.Columns(ColIndex).Width
Hope that helps.

Ron
(And if there is a better way I would love to see it- always looking to improve my code)
 
Thanks alot Theologian, with a little modification to display the list below the selected cell it works a treat.

List1.Top = DataGrid1.RowTop(DataGrid1.Row) + 500
List1.Left = DataGrid1.Columns(ColIndex).Left + 140
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top