473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

list box checked names

I got the index of all checked values, but I don't know how to read data of
that value?

For example.. in list box I have Names of users. First is John(index 1),
Second is Jack(index 2) and so on...
How to get the names ?

Hrcko
Nov 17 '05 #1
5 5726
Hi,

If you have all the indexes you can use the following statements:

YourList.Items[index].Text --> First column
YourList.Items[index].SubItems[columnIndex].Text --> other columns

Hope this helps
SAlva

Cheers
Salva

"Hrvoje Voda" wrote:
I got the index of all checked values, but I don't know how to read data of
that value?

For example.. in list box I have Names of users. First is John(index 1),
Second is Jack(index 2) and so on...
How to get the names ?

Hrcko

Nov 17 '05 #2
FIrst of all, when talking about a control, it's vitally important that
you say if you are using a WinForms control (for Windows apps), or a
WebControl (for ASP.NET apps). They are quite different, but they often
have the same names.

So, I'm going to assume that you are using a WinForms CheckedListBox
control, and that you've gotten the list of indexes via
checkedListBox.CheckedIndices property. Well, the simpliest thing is to
ignore that and use checkedListBox.CheckedItems which gives you exactly what
you want.

If you really want to continue using checkedListBox.CheckedIndices, you
can access the items via the Items property:

foreach( int i in checkedListBox.CheckedIndices)
{
string name = checkedListBox.Items[i] as string;
}

"Hrvoje Voda" <hr*********@luatech.com> wrote in message
news:d3**********@ss405.t-com.hr...
I got the index of all checked values, but I don't know how to read data of that value?

For example.. in list box I have Names of users. First is John(index 1),
Second is Jack(index 2) and so on...
How to get the names ?

Nov 17 '05 #3
I don't have Text after items.
I'm using checked ListBox.
"Salvador" <Sa******@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com...
Hi,

If you have all the indexes you can use the following statements:

YourList.Items[index].Text --> First column
YourList.Items[index].SubItems[columnIndex].Text --> other columns

Hope this helps
SAlva

Cheers
Salva

"Hrvoje Voda" wrote:
I got the index of all checked values, but I don't know how to read data
of
that value?

For example.. in list box I have Names of users. First is John(index 1),
Second is Jack(index 2) and so on...
How to get the names ?

Hrcko

Nov 17 '05 #4
The CheckedItemCollection stores objects so you need to cast each item to
its original type, which in your case appears to be System.String

foreach(int i in checkedListBox1.CheckedIndices)
{
string s = (string)checkedListBox1.Items[i];
// do something with s
}

--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 17 '05 #5
This doesn't work.

As a result I get : System.Windows.Forms.ListBox+SelectedObjectCollect

But, when I put items in listBoxCollection (in properties) then I get a
result.

Is it a problem because I'm using dataset?
"James Curran" <ja*********@mvps.org> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
FIrst of all, when talking about a control, it's vitally important that
you say if you are using a WinForms control (for Windows apps), or a
WebControl (for ASP.NET apps). They are quite different, but they often
have the same names.

So, I'm going to assume that you are using a WinForms CheckedListBox
control, and that you've gotten the list of indexes via
checkedListBox.CheckedIndices property. Well, the simpliest thing is to
ignore that and use checkedListBox.CheckedItems which gives you exactly
what
you want.

If you really want to continue using checkedListBox.CheckedIndices, you
can access the items via the Items property:

foreach( int i in checkedListBox.CheckedIndices)
{
string name = checkedListBox.Items[i] as string;
}

"Hrvoje Voda" <hr*********@luatech.com> wrote in message
news:d3**********@ss405.t-com.hr...
I got the index of all checked values, but I don't know how to read data

of
that value?

For example.. in list box I have Names of users. First is John(index 1),
Second is Jack(index 2) and so on...
How to get the names ?


Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
by: Stan Cook | last post by:
I was trying to take a list of files in a directory and remove all but the ".dbf" files. I used the following to try to remove the items, but they would not remove. Any help would be greatly...
8
by: Neil Zanella | last post by:
Hello, I would like to know why the W3C decided not to make the following valid XHTML: <input checked type="radio" name="foo" value="bar" />FooBar forcing people to write the following to...
8
by: tom | last post by:
I am new to SQL administration. >From a list of IDs that are the primary key in one table (i.e. Customer Table), I want to make changes in tables that use those IDs as a foreign key. ...
0
by: Steven | last post by:
Hi, I'm creating a custom checkbox list control which will take 2 arraylists as input. (One will contain Names and other will contain 0s and 1s. 0 - uncheck 1- check). I'm able to create the...
3
by: Hrvoje Voda | last post by:
I fill a checked listbox with name from dataset. I would like to go through that names and if I find the same name in list, then that line should be checked. How? Hrcko
1
by: platostoteles | last post by:
Hallo NG, I am new to JavaScript and would really appreciate any help to solve my problem. I am using the blow code in my form to validate form fields. What I would like to accomplish is that...
23
by: comp.lang.tcl | last post by:
I have a TCL proc that needs to convert what might be a list into a string to read consider this: ]; # OUTPUTS Hello World which is fine for PHP ]; # OUTPUT {{-Hello}} World, which PHP...
10
by: ryanshewcraft | last post by:
Let me start with my disclaimer by saying I'm new to computer programming and have doing it for the past three weeks. I may not be completely correct with all the jargon, so please bear with me. ...
1
by: Christina | last post by:
Hi, I've been looking at some code for dependent list boxes to adapt to a State and City list. There will only be 2 states for the first list box, and 3 cities in the second list box. When the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...

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.