|
-
Jan 18th, 2011, 12:39 PM
#1
Thread Starter
Junior Member
How can I add a button to a listbox (in another column)?
Hi there!
How can I add a button to a listbox? I mean: for every single item, one button. I want the button in another column.
Cheerz.
-
Jan 18th, 2011, 01:24 PM
#2
Re: How can I add a button to a listbox (in another column)?
I'm pretty sure you can't do that with a listbox. You can probably do that with a datagridview, and you could make that dgv look something like a listbox. Alternatively, you could create your own control, or just make something that looked and acted like a listbox but had buttons. The problem could be hooking up the button click event handlers to the buttons, though that is solvable, depending on which route you take.
My usual boring signature: Nothing
 
-
Jan 18th, 2011, 04:35 PM
#3
Hyperactive Member
Re: How can I add a button to a listbox (in another column)?
This is in the code bank by user NickThissen, is this what you're trying to do?
http://www.vbforums.com/showthread.php?t=599375
-
Jan 19th, 2011, 10:09 AM
#4
Thread Starter
Junior Member
Re: How can I add a button to a listbox (in another column)?
Works the datagridview the same as a listbox? (E.g: listbox1.items.add (MyItem)?
-
Jan 19th, 2011, 10:15 AM
#5
Re: How can I add a button to a listbox (in another column)?
No, the datagridview is a much different animal. It was really intended to display tabular data, such as datatables and dataviews, though you can use it to show any other kind of tabular data. I have never used it to hold controls, but have seen others do things like that.
Keep in mind that a listbox is a pretty simple animal. You could create something that looked very much like a listbox by putting a panel on the form with a vertical scroll bar on one side and a series of labels running from top to bottom. Keep all the items in a list and fill the labels from those items whenever the scrollbar moves and you have a listbox. It wouldn't be as convenient as the single package Listbox control, but if you do it right, the end user will never know the difference.
I am currently working on a project that has a horizontal list that works as I just described, except that, instead of strings in the list, there are pictures, and each picture has a radio button below it. It looks like you have a bunch of them and can scroll left and right through the images. In reality, there are four pictureboxes and four radio buttons, and the text of the radio button along with the image in the picturebox are set whenever the scrollbar is moved. You could do the same thing using strings and buttons on a panel. It may be easier than any other solution. Package it all into one class and you will have created a custom control.
My usual boring signature: Nothing
 
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|