PC Review


Reply
Thread Tools Rate Thread

CheckedListBox - Get the value of checked items

 
 
=?Utf-8?B?UmFt?=
Guest
Posts: n/a
 
      15th Jul 2004
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
 
Reply With Quote
 
 
 
 
Ollie
Guest
Posts: n/a
 
      15th Jul 2004
To get the index value of the selected item, read the value of the
SelectedIndex property

Ollie

"Ram" <(E-Mail Removed)> wrote in message
news:5CBF50D8-7552-4228-91E5-(E-Mail Removed)...
> 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



 
Reply With Quote
 
=?Utf-8?B?UmFt?=
Guest
Posts: n/a
 
      15th Jul 2004
Thank You

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

MessageBox.Show(clstApplications.SelectedValue.ToString());

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" <(E-Mail Removed)> wrote in message
> news:5CBF50D8-7552-4228-91E5-(E-Mail Removed)...
> > 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

>
>
>

 
Reply With Quote
 
Ollie
Guest
Posts: n/a
 
      15th Jul 2004
while ( myEnumerator.MoveNext() )
{
strIndex = myEnumerator.Current.ToString();
clstApplications.Items[strIndex ].Value
}


"Ram" <(E-Mail Removed)> wrote in message
news:62A0AF9D-44C8-4285-9F5D-(E-Mail Removed)...
> Thank You
>
> But I am not able to get the values of the selected items. When i tried

the following:
>
> MessageBox.Show(clstApplications.SelectedValue.ToString());
>
> 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" <(E-Mail Removed)> wrote in message
> > news:5CBF50D8-7552-4228-91E5-(E-Mail Removed)...
> > > 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

> >
> >
> >



 
Reply With Quote
 
Ollie
Guest
Posts: n/a
 
      15th Jul 2004
you are going to hace to cast the object to the correct type in this case
ListItem item.....

do you understand

"Ram" <(E-Mail Removed)> wrote in message
news:CB384D5D-3847-4E00-846C-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> > news:62A0AF9D-44C8-4285-9F5D-(E-Mail Removed)...
> > > Thank You
> > >
> > > But I am not able to get the values of the selected items. When i

tried
> > the following:
> > >
> > > MessageBox.Show(clstApplications.SelectedValue.ToString());
> > >
> > > 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" <(E-Mail Removed)> wrote in message
> > > > news:5CBF50D8-7552-4228-91E5-(E-Mail Removed)...
> > > > > 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
> > > >
> > > >
> > > >

> >
> >
> >



 
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
Checked items in checkedlistbox gets unchecked diego Microsoft VB .NET 0 29th Mar 2007 02:28 AM
Checkedlistbox - can you bind the checked or not checked property? pbaddorf@yahoo.com Microsoft Dot NET Framework Forms 0 19th Jun 2006 02:08 AM
Deleting checked items in CheckedListBox Robke Microsoft Dot NET Framework Forms 1 26th Oct 2004 02:56 PM
Getting text associated with checked items in a checkedlistbox control rob Microsoft Dot NET 0 19th Sep 2003 04:10 AM
Checkedlistbox set checked items during initialisation Laurent GAYE Microsoft Dot NET Framework Forms 0 25th Jun 2003 10:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:13 PM.