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

TListBox: add row seperators and control horizontal scroll bar 1

Status
Not open for further replies.

roadbeer69

Programmer
Mar 24, 2007
14
US
Hi All,

I've two questions related to TListBox that I've been unable to find the answer to. I'm hoping someone here can help.

Backgroud: My app has a TListBox into which users can add strings by using a TEditBox.

Questions:
1. I'd like to have the strings in the TListBox separated by some sort of line, sort of like a grid. I have been unable to figure out how to do this. Is this even possible? If so, how? If not, is there another control that will do what I want? I've looked at the TStringGrid object, but that seems a bit heavy-weight for what I want to do.

2. When a user enters a string that is too wide to be displayed in the TListBox, I'd like to set the TLIstBox's ScrollWidth property such that the horizontal scroll bar has enough travel to display the string. Further, if a longer string is added, I'd like to be able to increase the length of the scroll bar. My problem is that ScrollWidth is in pixels. Is there an easy way to determine the width of a string in the TListBox in pixels so that I can set the ScrollWidth property?

Thanks very much in advance!
Jeff
 
I must admit that I have not done it but you can create an owner drawn list box. See this article and this one for starters.

James P. Cottingham
-----------------------------------------
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
Thanks James. That will help, and also answers a bunch of other questions I had while introducing me to a topic I was figuring I was going to have to dig into sooner or later.

One star for you!

Jeff
 
I should mention, for anyone else who reads this thread, that using TListView combined with 2ffat's suggestion can give a powerful list box that will help do the things I mention in the my original post. For exapmle, TListView gives the ability to do grid lines.
 
Glad I could help and thanks for the star!


James P. Cottingham
-----------------------------------------
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top