Detect button caption based from listbox

Hi,

I have a Listbox data,

Button1 Button2 Button3 Button4

and 4 buttons, the button’s text based from Listbox row content.
what I need is, if i do clicking the row, if the button text is equal with row selected text, then bold the text of button.
Does this method is possible to do it in xojo ?

Thanks,
Regards,
Arief

pushbutton1.bold=(listbox.text=pushbutton1.text)

was the first thing to come to mind

Hi Mr. S,

the code is work only on a pushbutton1,
I have 4 PushButtons, if I do select the row with equal text, the result could be button 1, 2,3 or 4, not only in button1

Do I have to create an array button for this ?

Thanks
Regards,
Arief

Dave’s suggestion would work if you apply it to all your buttons. So you could do something like this in the ListBox.Change event handler:

PushButton1.Bold = Me.List(Me.ListIndex) = PushButton1.Caption PushButton2.Bold = Me.List(Me.ListIndex) = PushButton2.Caption PushButton3.Bold = Me.List(Me.ListIndex) = PushButton3.Caption PushButton4.Bold = Me.List(Me.ListIndex) = PushButton4.Caption

A control set might be cleaner if the number of buttons varies at all. So if your PushButton’s are in a control set then this code in the ListBox.Change event handler would work:

For i As Integer = 0 To 3 PushButton1(i).Bold = Me.List(Me.ListIndex) = PushButton1(i).Caption Next

Here’s an example project that does not rely on string comparison to handle the bolding:
Listbox Control Example

It’s very simple, you store the PushButton instance as a row tag and then the selected row is bolded without needing a control set.

Wow, Paul… I just started to write exactly that suggestion. But I got a call and ran off. Now you beat me to it.
Yes, a controlSet is what I often use in this case.

I kind of do the same thing with a PagePanel and a bunch of buttons in a controlSet. I loop through the pages and style the buttons accordingly.
I use Rounded and Recessed buttons to tell which page I have selected. This way I have a nice clean Tab Panel, kind of thing.

nice…!

Thanks for all the helps…

Regards,
Arief