PC Review


Reply
Thread Tools Rate Thread

Adding controls to items in a listbox

 
 
=?Utf-8?B?Sm9obiBSLg==?=
Guest
Posts: n/a
 
      29th Dec 2004
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.
 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      30th Dec 2004
John,

Do you mean something as a listview in detailview?

Cor

"John R." <(E-Mail Removed)>

>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.



 
Reply With Quote
 
=?Utf-8?B?Sm9obiBSLg==?=
Guest
Posts: n/a
 
      30th Dec 2004
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." <(E-Mail Removed)>
>
> >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.

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding items in listbox =?Utf-8?B?TWFobW91ZCBTaGFiYW4=?= Microsoft C# .NET 2 22nd Nov 2007 10:00 AM
Urgent - Compare Items in Two Listbox Controls using VB.Net 2003 =?Utf-8?B?U2hhcmlx?= Microsoft Dot NET Framework Forms 2 24th Jun 2005 06:23 PM
Adding Items to a ListBox-Unique Items Only jpendegraft Microsoft Excel Programming 2 2nd May 2004 02:27 AM
Adding items to ListBox sach Microsoft VC .NET 4 23rd Mar 2004 10:33 AM
Adding a Controls Listbox via VBA Michael Singmin Microsoft Excel Programming 2 13th Mar 2004 06:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:36 AM.