473,583 Members | 3,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CheckedListBox - Get the value of checked items

Ram
Dear Helpers,

I assigened values to checkedlistbox control in the following way

cList.DataSourc e=oDs.Tables[bTableNo].DefaultView;
cList.DisplayMe mber=oDs.Tables[bTableNo].Columns[1].ToString();
cList.ValueMemb er=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 29095
To get the index value of the selected item, read the value of the
SelectedIndex property

Ollie

"Ram" <Ra*@discussion s.microsoft.com > wrote in message
news:5C******** *************** ***********@mic rosoft.com...
Dear Helpers,

I assigened values to checkedlistbox control in the following way

cList.DataSourc e=oDs.Tables[bTableNo].DefaultView;
cList.DisplayMe mber=oDs.Tables[bTableNo].Columns[1].ToString();
cList.ValueMemb er=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 (clstApplicatio ns.SelectedValu e.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.Collecti ons.IEnumerator myEnumerator = clstApplication s.CheckedIndice s.GetEnumerator ();

while ( myEnumerator.Mo veNext() )
{
strIndex = myEnumerator.Cu rrent.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*@discussion s.microsoft.com > wrote in message
news:5C******** *************** ***********@mic rosoft.com...
Dear Helpers,

I assigened values to checkedlistbox control in the following way

cList.DataSourc e=oDs.Tables[bTableNo].DefaultView;
cList.DisplayMe mber=oDs.Tables[bTableNo].Columns[1].ToString();
cList.ValueMemb er=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.Mo veNext() )
{
strIndex = myEnumerator.Cu rrent.ToString( );
clstApplication s.Items[strIndex ].Value
}
"Ram" <Ra*@discussion s.microsoft.com > wrote in message
news:62******** *************** ***********@mic rosoft.com...
Thank You

But I am not able to get the values of the selected items. When i tried the following:
MessageBox.Show (clstApplicatio ns.SelectedValu e.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.Collecti ons.IEnumerator myEnumerator = clstApplication s.CheckedIndice s.GetEnumerator ();
while ( myEnumerator.Mo veNext() )
{
strIndex = myEnumerator.Cu rrent.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*@discussion s.microsoft.com > wrote in message
news:5C******** *************** ***********@mic rosoft.com...
Dear Helpers,

I assigened values to checkedlistbox control in the following way

cList.DataSourc e=oDs.Tables[bTableNo].DefaultView;
cList.DisplayMe mber=oDs.Tables[bTableNo].Columns[1].ToString();
cList.ValueMemb er=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*@discussion s.microsoft.com > wrote in message
news:CB******** *************** ***********@mic rosoft.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.Mo veNext() )
{
strIndex = myEnumerator.Cu rrent.ToString( );
clstApplication s.Items[strIndex ].Value
}
"Ram" <Ra*@discussion s.microsoft.com > wrote in message
news:62******** *************** ***********@mic rosoft.com...
Thank You

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

MessageBox.Show (clstApplicatio ns.SelectedValu e.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.Collecti ons.IEnumerator myEnumerator =

clstApplication s.CheckedIndice s.GetEnumerator ();

while ( myEnumerator.Mo veNext() )
{
strIndex = myEnumerator.Cu rrent.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*@discussion s.microsoft.com > wrote in message
> news:5C******** *************** ***********@mic rosoft.com...
> > Dear Helpers,
> >
> > I assigened values to checkedlistbox control in the following way
> >
> > cList.DataSourc e=oDs.Tables[bTableNo].DefaultView;
> > cList.DisplayMe mber=oDs.Tables[bTableNo].Columns[1].ToString();
> > cList.ValueMemb er=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
3294
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 caseIssuesCheckedListBox.CheckedIndices) { for (int i = 0; i < caseIssuesCheckedListBox.Items.Count; i++) { if(caseIssuesCheckedListBox.GetItemCheckState(index) == CheckState.Checked)
2
2410
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 user can click a button to toggle back-and-forth between showing all or some. The question we have is maintaining state of the CheckedListBox. In...
2
2279
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 checkedlistbox, but always have at list one item always checked. so if the user has the last item checked and he/she wants to uncheck it, the item should reset...
1
1126
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 first item on the Checkedlistbox should be checked, I can do this alreay this is not the problem I'm having. what I want is If ItemIndex0 =...
0
1700
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 CheckedListBox.SelectedIndex = I DoMySub(CheckedListBox.SelectedItem) Next The first line in the For loop (CheckedListBox.SelectedIndex = I) sometimes
5
6848
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 folder. The "check mark" for each item in the control is determined by the boolean value of a custom property field of the file. That value is found...
8
10769
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 boxes from being checked or unchecked.. i want them to always show their default value which i have fetched from a xml file.. and also i dont want...
6
4173
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 database. when a user clicks any of the above values and saves the form, the item's "value" is getting saved in database. and when a user logs back in,...
2
2812
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 now but theres a problem there too: When i was using checkboxes i was doing it like this
0
7896
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...
0
8328
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...
1
7936
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8195
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5701
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...
0
5375
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...
0
3820
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2334
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
1434
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.