469,950 Members | 2,107 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

Adding controls to items in a listbox

I want to have a listbox that shows a checkbox and a textbox.

I created a user control that has a checkbox and a textbox in it and have
been trying to add it to a listbox but I can't get it to show up for each
item I add to the listbox.

foreach (Column column in columns)
{
ColumnsListBox.Items.Add(column.Name);
ColumnsListBox.Controls.Add(new ColumnListControl(true, column.Name,
column.Name));
}

I've also looked at using an Owner Draw listbox but can't figure that out
either.

I basically need something that looks like a listbox with 2 columns in it --
a checkbox and a textbox.

How can I get that to work so I can add items to the object and set the
subitem values?

Thanks in advance.
Nov 16 '05 #1
2 22915
John,

Do you mean something as a listview in detailview?

Cor

"John R." <jo*******@newsgroups.nospam>
I want to have a listbox that shows a checkbox and a textbox.

I created a user control that has a checkbox and a textbox in it and have
been trying to add it to a listbox but I can't get it to show up for each
item I add to the listbox.

foreach (Column column in columns)
{
ColumnsListBox.Items.Add(column.Name);
ColumnsListBox.Controls.Add(new ColumnListControl(true,
column.Name,
column.Name));
}

I've also looked at using an Owner Draw listbox but can't figure that out
either.

I basically need something that looks like a listbox with 2 columns in
it --
a checkbox and a textbox.

How can I get that to work so I can add items to the object and set the
subitem values?

Thanks in advance.

Nov 16 '05 #2
First I should say I'm doing this in a Windows Form.

I would prefer a listbox but I don't care if it's a listview in detailview
or not.

I basically want something like a listbox that has a list containing a
checkbox and a textbox that scrolls.

So the list would look like this:

checkbox textbox
checkbox textbox
checkbox textbox

I tried creating a user control that has a checkbox and textbox and putting
that onto a listbox but I wasn't able to get that to work.

The closest I've come is using a ListView. Except the problem is that the
controls don't scroll. If I could get the scrolling to work then I'd have it.

Here's what I've got so far:

foreach (Column column in columns)
{
ListViewItem item = new ListViewItem();
item.Text = column.Name;
listView1.Items.Add(item);

ColumnListControl control = new ColumnListControl(true, column.Name,
column.Name);
control.Height = item.Bounds.Height;
control.Location = new Point(0, item.Bounds.Y);
listView1.Controls.Add(control);
}
-------------------------
"Cor Ligthert" wrote:
John,

Do you mean something as a listview in detailview?

Cor

"John R." <jo*******@newsgroups.nospam>
I want to have a listbox that shows a checkbox and a textbox.

I created a user control that has a checkbox and a textbox in it and have
been trying to add it to a listbox but I can't get it to show up for each
item I add to the listbox.

foreach (Column column in columns)
{
ColumnsListBox.Items.Add(column.Name);
ColumnsListBox.Controls.Add(new ColumnListControl(true,
column.Name,
column.Name));
}

I've also looked at using an Owner Draw listbox but can't figure that out
either.

I basically need something that looks like a listbox with 2 columns in
it --
a checkbox and a textbox.

How can I get that to work so I can add items to the object and set the
subitem values?

Thanks in advance.


Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Big D | last post: by
2 posts views Thread by avivgur | last post: by
4 posts views Thread by MattB | last post: by
3 posts views Thread by Ankit Aneja | last post: by
2 posts views Thread by Oleg Ogurok | last post: by
6 posts views Thread by crazyjh | last post: by
3 posts views Thread by Mark Denardo | last post: by
2 posts views Thread by joyce85 | last post: by
2 posts views Thread by Chris Botha | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.