473,320 Members | 2,177 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,320 software developers and data experts.

CheckedListBox - Get the value of checked items

Ram
Dear Helpers,

I assigened values to checkedlistbox control in the following way

cList.DataSource=oDs.Tables[bTableNo].DefaultView;
cList.DisplayMember=oDs.Tables[bTableNo].Columns[1].ToString();
cList.ValueMember=oDs.Tables[bTableNo].Columns[0].ToString();

where oDs is DataSet

the purpose is to display the batchname and allow the user to select multiple batches. To identify the user selection i assigned the BatchID to Value Member.

Once the user makes his selection i want to get the selected batch id. I am able to get the display name by verifying if the item is checked or not. But i dont want the display name. I want to get the IDs associated to that names. I tried using CheckedIndex collection with out any success.

Please advice. I am new to C#

Thanks & Regards
Nov 16 '05 #1
4 29072
To get the index value of the selected item, read the value of the
SelectedIndex property

Ollie

"Ram" <Ra*@discussions.microsoft.com> wrote in message
news:5C**********************************@microsof t.com...
Dear Helpers,

I assigened values to checkedlistbox control in the following way

cList.DataSource=oDs.Tables[bTableNo].DefaultView;
cList.DisplayMember=oDs.Tables[bTableNo].Columns[1].ToString();
cList.ValueMember=oDs.Tables[bTableNo].Columns[0].ToString();

where oDs is DataSet

the purpose is to display the batchname and allow the user to select multiple batches. To identify the user selection i assigned the BatchID to
Value Member.
Once the user makes his selection i want to get the selected batch id. I am able to get the display name by verifying if the item is checked or not.
But i dont want the display name. I want to get the IDs associated to that
names. I tried using CheckedIndex collection with out any success.
Please advice. I am new to C#

Thanks & Regards

Nov 16 '05 #2
Ram
Thank You

But I am not able to get the values of the selected items. When i tried the following:

MessageBox.Show(clstApplications.SelectedValue.ToS tring());

I got the value of last selected item. But i am not sure how to get the values of all selected items.

Also i am able to get the index of all selected items by doing the following:

System.Collections.IEnumerator myEnumerator = clstApplications.CheckedIndices.GetEnumerator();

while ( myEnumerator.MoveNext() )
{
strIndex = myEnumerator.Current.ToString();
}
Not sure where to go from here

Please Advice

Thanks & Regards
Ram

"Ollie" wrote:
To get the index value of the selected item, read the value of the
SelectedIndex property

Ollie

"Ram" <Ra*@discussions.microsoft.com> wrote in message
news:5C**********************************@microsof t.com...
Dear Helpers,

I assigened values to checkedlistbox control in the following way

cList.DataSource=oDs.Tables[bTableNo].DefaultView;
cList.DisplayMember=oDs.Tables[bTableNo].Columns[1].ToString();
cList.ValueMember=oDs.Tables[bTableNo].Columns[0].ToString();

where oDs is DataSet

the purpose is to display the batchname and allow the user to select

multiple batches. To identify the user selection i assigned the BatchID to
Value Member.

Once the user makes his selection i want to get the selected batch id. I

am able to get the display name by verifying if the item is checked or not.
But i dont want the display name. I want to get the IDs associated to that
names. I tried using CheckedIndex collection with out any success.

Please advice. I am new to C#

Thanks & Regards


Nov 16 '05 #3
while ( myEnumerator.MoveNext() )
{
strIndex = myEnumerator.Current.ToString();
clstApplications.Items[strIndex ].Value
}
"Ram" <Ra*@discussions.microsoft.com> wrote in message
news:62**********************************@microsof t.com...
Thank You

But I am not able to get the values of the selected items. When i tried the following:
MessageBox.Show(clstApplications.SelectedValue.ToS tring());

I got the value of last selected item. But i am not sure how to get the values of all selected items.
Also i am able to get the index of all selected items by doing the following:
System.Collections.IEnumerator myEnumerator = clstApplications.CheckedIndices.GetEnumerator();
while ( myEnumerator.MoveNext() )
{
strIndex = myEnumerator.Current.ToString();
}
Not sure where to go from here

Please Advice

Thanks & Regards
Ram

"Ollie" wrote:
To get the index value of the selected item, read the value of the
SelectedIndex property

Ollie

"Ram" <Ra*@discussions.microsoft.com> wrote in message
news:5C**********************************@microsof t.com...
Dear Helpers,

I assigened values to checkedlistbox control in the following way

cList.DataSource=oDs.Tables[bTableNo].DefaultView;
cList.DisplayMember=oDs.Tables[bTableNo].Columns[1].ToString();
cList.ValueMember=oDs.Tables[bTableNo].Columns[0].ToString();

where oDs is DataSet

the purpose is to display the batchname and allow the user to select

multiple batches. To identify the user selection i assigned the BatchID to Value Member.

Once the user makes his selection i want to get the selected batch id.
I am able to get the display name by verifying if the item is checked or not. But i dont want the display name. I want to get the IDs associated to that names. I tried using CheckedIndex collection with out any success.

Please advice. I am new to C#

Thanks & Regards


Nov 16 '05 #4
you are going to hace to cast the object to the correct type in this case
ListItem item.....

do you understand

"Ram" <Ra*@discussions.microsoft.com> wrote in message
news:CB**********************************@microsof t.com...
I tried it but no luck. The reason is there is no definition for 'Value'

Here is the error i received
'object does not contain a definition for Value'

Thanks & Regards

"Ollie" wrote:
while ( myEnumerator.MoveNext() )
{
strIndex = myEnumerator.Current.ToString();
clstApplications.Items[strIndex ].Value
}
"Ram" <Ra*@discussions.microsoft.com> wrote in message
news:62**********************************@microsof t.com...
Thank You

But I am not able to get the values of the selected items. When i tried
the following:

MessageBox.Show(clstApplications.SelectedValue.ToS tring());

I got the value of last selected item. But i am not sure how to get
the values of all selected items.

Also i am able to get the index of all selected items by doing the

following:

System.Collections.IEnumerator myEnumerator =

clstApplications.CheckedIndices.GetEnumerator();

while ( myEnumerator.MoveNext() )
{
strIndex = myEnumerator.Current.ToString();
}
Not sure where to go from here

Please Advice

Thanks & Regards
Ram

"Ollie" wrote:

> To get the index value of the selected item, read the value of the
> SelectedIndex property
>
> Ollie
>
> "Ram" <Ra*@discussions.microsoft.com> wrote in message
> news:5C**********************************@microsof t.com...
> > Dear Helpers,
> >
> > I assigened values to checkedlistbox control in the following way
> >
> > cList.DataSource=oDs.Tables[bTableNo].DefaultView;
> > cList.DisplayMember=oDs.Tables[bTableNo].Columns[1].ToString();
> > cList.ValueMember=oDs.Tables[bTableNo].Columns[0].ToString();
> >
> > where oDs is DataSet
> >
> > the purpose is to display the batchname and allow the user to
select > multiple batches. To identify the user selection i assigned the

BatchID to
> Value Member.
> >
> > Once the user makes his selection i want to get the selected batch
id. I
> am able to get the display name by verifying if the item is checked
or not.
> But i dont want the display name. I want to get the IDs associated
to that
> names. I tried using CheckedIndex collection with out any success.
> >
> > Please advice. I am new to C#
> >
> > Thanks & Regards
>
>
>


Nov 16 '05 #5

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

Similar topics

2
by: 0582 | last post by:
Dear helpers, how do I get the value indeces of items checked in CheckedListBox? I have tried to do this but It doesn't seem work?? foreach(int index in...
2
by: CC | last post by:
Hi, We are populating a CheckedListBox from a database. Based on a selection by the user, the CheckedListBox either contains ALL possible members of a set, or a subset of possible members. The...
2
by: Manuel Canas | last post by:
Hi there, I'm having this dilema with a checkedlistbox. I have an array of items in there, what I want to accomplish is the following; The user could check all the items in the...
1
by: Manuel Canas | last post by:
Hi There, I'm looking for ideas, advices, hints on how to accomplish the following; On a CheckedListBox I have a list of names or whatever, the behavior that I want to accomplish is this; the...
0
by: Terry Olsen | last post by:
Dim dirs() as string = Directory.GetDirectories(MyPath) CheckedListBox.DataSource = dirs CheckedListBox.Update For I as Integer = 0 To CheckedListBox.Items.Count - 1...
5
by: mabond | last post by:
Hi Can't believe I've not been able to find the answer to this in the on-line help. I have a CheckedListBox which, via a timer control, is populated with the names of files in a network...
8
by: ameen.abdullah | last post by:
Hi Guys, I have a checked list box on my form.. the purpose of this checkbox is to indicate that the option is enabled or disabled.. I just want to ask if there is a way to disable these check...
6
by: painkiller | last post by:
language: vb.net environment: windows forms .net : v1.1 i am having a checkedlistbox control that display document category such as text, image, video, audio etc. these values are coming from...
2
by: zubair1 | last post by:
Hello, i'm in a bit of problem here :( I've been using Checkboxes on my app - but it has been horrible, since my app has alot of checkboxes - over 20-30. But i decided to use checkedlistbox...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.