Editable listbox?

G

GT

Hello all,

I want to have a control which is something like the "Properties
Window", i.e the first column's fields are fixed but the second column's
fields are editable.

The data for the first column is populated by the user selecting a range
of data from a spreadsheet (via a refedit) so it can vary in size. The
second column is initially populated with a default value that the user
can override.

I'm not a particularaly experienced VB programmer so I have probably
missed some obvious control out there that's ideal for the job.

Anyway, the closest I've come to this solution is by trying to
dynamically create a "table" from labels (for the 1st column) and
text-boxes (for the 2nd column) but I dont seem to get any events for
the dynamic controls.

I looked into the DBGrid but this doesn't seem to be what I want either.

It's probably worth mentioning it's Excel97 on Win2k

If anybody out there can point me in the direction of a suitbale control
I'd be very grateful.

TIA
G
 
D

Dick Kusleika

G

I can't think of a control that does just what you want. You could use a
two column listbox, but you wouldn't be able to edit directly in the
listbox. You could have the user select an entry, then click a button to
change the value. The button would show an InputBox where the user could
type in the value. If you need help with the code for that, post back.

Actually, I like the label/textbox table idea. What you need to do is
determine the maximum number of entries there could be and create a
label/textbox pair for each of those. Change the visible property of those
controls to False so they are invisible. Set up all your event code for the
textboxes. Then, when you're ready to populate the controls (presumably in
the Initialize event), set the Visible property to True for only the
controls that you'll need. The other controls will still be there, but the
user won't be able to see them or trigger any of there events.

Setting up the controls at design-time will make your form run faster and
allow you to create the events more easily than creating them on the fly.
Your only challenge may be resizing the userform so you don't have a bunch
of blank space, but that's definitely doable and still easier than creating
them on the fly. I guess the key may be how well you can predict the
maximum number of label/textbox pairs you will need.

If you have follow up questions, be sure to post back.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top