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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listboxes: Vertical Scroll and Drop Down Boxes 2

Status
Not open for further replies.

rennis

Programmer
Dec 6, 2006
80
CA
First Question:
How is it possible to add a vertical scroll bar to a listbox if it is needed? I've tried EnsureVisible method, but this did not seem to resolve the issue, whether Its the wrong method to use or I was using it incorrectly.

Second Question:
Is it possible to add a drop down box as a column header in a listbox? I've been researching this as well but I have been unsuccessful in being able to determine the proper way on how to go about doing so.

Any help would be greatly appreciated.
 
In response to your first question, EnsureVisible would generally be used in conjunction with displaying particular items within the listview and I'm pretty sure the default behaviour of a listview would be to display a scroll bar if required.

Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
THanks harley for your quick reply. Is there any option to select the vscroll bar because presently, there is no vscroll bar showing if the number of items goes past the width of the listbox. If it makes any difference the list view is lvwReport.
 
Ah, to clear this up do you mean a horizontal scroll bar if the data is too wide?

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
No the vertical scroll bar if the data is too long. Sorry for the confusion.
 
OK, that's what I thought originally and should be the default behaviour of the Listview. I'll be honest, I'm not sure why this isn't the case with your listview. Sorry [sad]

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Thanks for your help.

Anyone know anything regarding my second question?
 
You could try the techniques suggested in faq222-3262

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Thanks johnwm for your help. I greatly appreciate it. However, I do have the listview programmed for what i want it to do up to this point, and its what is required. Is there anyway to add the drop down box to the listview instead of switching to a msflexgrid?

Thanks
 
rennis, I suppose johnwm pointed you to the FAQ because it also shows how to position a text box, or any other control, to a grid's cell. The same technique can be used for other grids and lists and can be used to position a combo box.

So, if you add a combo box and set it's left and top position relative to the column header left and top, and it's width to the column head's width, you should have what you want.

Combo1.Left = MyListView.Left + MyListView.ColumnHeaders(1).Left + 45
Combo1.Top = MyListView.Top + 15
Combo1.Width = MyListView.ColumnHeaders(1).Width + 30

It may be easier, because of resizing and repositioning of the form, to hide the combo box, and add an arrow icon (similar to that of the combo box's) to the column header, and when the column header is clicked, position and show the combo.
 
Sorry I wasn't clear - use the techniques, not the code. You can pick up x and y values in the Listview and translate them into cell positions, then use those to position your other elements

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Thank you both very much. I greatly appreciate it. My apologizes on the confusion.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top