Board index » cppbuilder » TScrollBox(I think) question..

TScrollBox(I think) question..

Hi all,

I am not sure if TScrollBox is what I want to use, however, here is what
I want to do...
I want to have a list of text "lines" with that has a vertical
scrollbar,where each text item has it's own font color, and the whole
this has one handler for doubleclicks on one of the text lines.

so, for example, what you have in your newsreader right now, where your
unread headers are bold, and read are not, double clicking opens the
message, and there is a vertical scroll bar of the headers if needed.

I thought maybe I could use a TScrollBox, with an array of TLabel
components, but don't quite know what to do with the double click
handler without writing one for each Tlabel component added.

I have got to be missing something simple, am I on the right track? If
there is a better way, please advise.

here is some pseudo-code for what I "think" I need to do:

TLabel *TextList;

for(inti=0;i<10;i++){
    TextList[0]->Caption="Text";
    TextList[0]->Font->Color=i;

Quote
}//end for

Some TScrollBox on my form is named NamesBox
NamesBox->Controls=TextList

TextList->[i+1]->Caption="New Text";
TextList->[i+1]->Color=clRed;

NamesBox->Upadte();

will this do what I want?

Thanks,

Jay

 

Re:TScrollBox(I think) question..


Hi, Jay!

I'd try a TStringGrid with owner draw for the cells.

That should be a lot easier.

------
Mark Cashman, TeamB C++ Builder
http://www.temporaldoorway.com/programming/index.htm
C++ Builder, JBuilder programming information
Home of The C++ Builder Programmer's Webring - Join us!
------

Re:TScrollBox(I think) question..


Hi Jay --
[snip]

Quote
> I thought maybe I could use a TScrollBox, with an array of TLabel
> components, but don't quite know what to do with the double click
> handler without writing one for each Tlabel component added.

In addition to Mark's suggestion, check out the TListView component, and
specifically the Custom Draw service.  This control is one of the most
sophisticated common controls out there, and can be configured to fit most
situations.

Good luck.

--
Damon Chandler (TeamB)
http://bcbcaq.freeservers.com

Other Threads