473,597 Members | 2,726 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(colum n.Name);
ColumnsListBox. Controls.Add(ne w ColumnListContr ol(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 23349
John,

Do you mean something as a listview in detailview?

Cor

"John R." <jo*******@news groups.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(colum n.Name);
ColumnsListBox. Controls.Add(ne w ColumnListContr ol(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);

ColumnListContr ol control = new ColumnListContr ol(true, column.Name,
column.Name);
control.Height = item.Bounds.Hei ght;
control.Locatio n = new Point(0, item.Bounds.Y);
listView1.Contr ols.Add(control );
}
-------------------------
"Cor Ligthert" wrote:
John,

Do you mean something as a listview in detailview?

Cor

"John R." <jo*******@news groups.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(colum n.Name);
ColumnsListBox. Controls.Add(ne w ColumnListContr ol(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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
42564
by: Big D | last post by:
Hi all, I'm having a problem adding controls to a panel dynamically. I have a usercontrol that I create and try to add 5 times to the panel, but I only ever see the first control. I know it's the first, because a property of the userControl is to display it's name. The code I have is: //Add detatil widgets to the panel CustControls.DetailWidget x;
2
3716
by: avivgur | last post by:
Hello, I am writing a program in Visual C# and I have encountered a problem. In my program I want to dynamically create a multitude of controls (thousands) on a form. The problem is that calling the Controls.Add() method several times or even calling the Controls.AddRange() method once can take a huge amount of time. Therefore, I would like to be able to run the loop that creates the controls on a different thread and meanwhile give the user...
4
3603
by: MattB | last post by:
Hello. I'm creating a page to edit a person's record (name address, etc) using a DataGrid. I want the fields that can be edited to be created at runtime based on a list of columns in web.config. This is working fine, and I can add a control (TextBox or DropDownList) dynamically for the user to fill in a value. This works well for just adding controls for data entry. Now, I want to add validators on the fly as well and it not going quite...
3
2336
by: Ankit Aneja | last post by:
I have a strange situation and I have no idea how to solve this. Its a Recruitment Search Page,in the Admin Page, for every button click event the Admin Person has to create a checkbox on the users page. So whenever the Admin person comes to know about the new category in the market he will be adding as different Sub-Categories for example ABAP, BDC etc..etc.. on every click event as Checkboxes. And these controls(checkboxes) should remain...
2
1491
by: Oleg Ogurok | last post by:
Hi all, Does anyone have example of adding controls on the client side (DHTML) and then persisting them as ASP.NET server controls on the server side? For example, a page has an <input> box for entering e-mail address and a button <Add more addresses>.
6
1523
by: crazyjh | last post by:
hello i want to add some controls in according of the time. but when the time change, i call the method again to add controls again,No effect! i think maybe i should unload the controls adding before,how can i unload it?? pls help me,thanks
3
5479
by: Mark Denardo | last post by:
I'm trying to dynamically create and add controls to a web page: Label obj1 = new Label(); DropDownList obj2 = new DropDownList(); Controls.Add(obj1); Controls.Add(obj2); But I get the following error when the DDL is added (but not the Label): "Control 'ctl07' of type 'DropDownList' must be placed inside a form tag
2
1414
by: joyce85 | last post by:
hai i had 1 prblm of adding item to listbox.. but i succeeded that with the help of datasouce.. but i am not able to modify items in listbox..how can i do that my coding are
2
359
by: Chris Botha | last post by:
I am adding controls dynamically to the page as per the samples there are on the Web and it works - I can create text boxes, buttons, my own user controls, whatever, on the fly and initialize them and add them to a placeholder no problem. However when I post back and the page displays again then all of the controls are gone. I create them when the IsPostBack is false, because the idea is to validate on post back, and if the data is invalid...
4
4470
by: Lewis Holmes | last post by:
Hi I have the following situation in one of my asp.net pages. The user can add multiple table rows to a form by selecting a button. These rows can contain asp.net controls. When this button is selected, the row is added using JavaScript. The script uses cloneNode to clone a hidden template row and all of its children and then adds the new row to the table, updates all of the child control Ids and sets visibility etc. The hidden...
0
7979
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7894
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8281
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8381
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
5847
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5437
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2409
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1497
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1245
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.