473,568 Members | 2,964 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CheckedListBox class question

Hi all,

I've populated a checkedlistbox control with a dataset as follows:

chklstTasks.Dat aSource = dsTask.Tables(" Task").DefaultV iew
chklstTasks.Dis playMember = "header"
chklstTasks.Val ueMember = "task_id"

and in my button_click event, i would like to traverse the items in this
chklstTasks and if an item is
checked, i want to pop a message box to display "header" and "task_id" of
that item.

i tried as follow and got stuck. any help is appreciated. thanks in advance.

For i = 0 To chklstTasks.Che ckedItems.Count - 1
' how to i check if each item is checked and if check, what is the
task_id?

Next
Nov 19 '05 #1
2 3083
Hi Fergus,
Thanks much. That's exactly what i was looking for. It works !!

I have one more question:
i want to traverse the whole list using Items collection and check each
item with checkstate and do something based on their state. Can I still use
DataRowView?
How do I use CheckState? from which object?
I tried ..

For i = 0 To chklstTasks.Ite ms.Count - 1
drvTask = CType(chklstTas ks.Items(i), DataRowView)
' i want to do something like this ..
selec case drvTask.CheckSt ate
case 'unchecked
case ' checked
case ' intermediate
end select
Next

thanks again.
"Fergus Cooney" <wo****@tesco.n et> wrote in message
news:#x******** ******@TK2MSFTN GP10.phx.gbl...
Hi Mike,

chklstTasks.Ite ms contains the list of ALL the items in the list, while chklstTasks.Che ckedItems contains ONLY those which have been checked. So
your first task (get all the checked items) is done for you.

Each of the items in chklstTasks.Che ckedItems is a DataRowView, however it is stored as an Object type. So you'll need to assign each one to a
DataRowView in order to access it.

Then it's familiar stuff.

Dim drvTask As DataRowView
Dim sInfo As String

For I = 0 To chklstTasks.Che ckedItems.Count - 1
drvTask = chklstTasks.Che ckedItems (I)
sInfo = drvTask ("header") & ", " & drvTask ("task_id")
'Do something with sInfo
Next

Best wishes,
Fergus

Nov 19 '05 #2
Howdy Mike,

One question - three question marks!!! - no problem :-)

Q. Can I still use DataRowView?
A. Yes, you can still use DataRowView. In fact, in your case, you must,
because that's what the items are. I note that in your code you are doing a
type conversion. Have you found that you need to? It worked fine when I did
it without:
drvTask = chklstTasks.Ite ms(i)
vs.
drvTask = CType (chklstTasks.It ems(i), DataRowView)
Q. How do you use CheckState? From which object?
A. Using chklstTasks.Get ItemCheckState( i)

Dim S as String = ""
Dim I As Integer
For I = 0 To chklstTasks.Ite ms.Count - 1
Select Case chklstTasks.Get ItemCheckState( i)
Case CheckState.Chec ked: S = S & "X"
Case CheckState.Inde terminate: S = S & "?"
Case CheckState.Unch ecked: S = S & "O"
End Select
Next
S = S: Stop

Regards,
Fergus
Nov 19 '05 #3

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

Similar topics

0
3457
by: | last post by:
David, A partial answer to your question: The 'MultiColumn' property of a CheckedListBox does not cause it to display multiple FIELDS of an item... it causes it to display the items themselves in multiple columns. In other words, if you have 20 items in your Items
4
3731
by: Reza | last post by:
Hi, I want to check one of the memebrs of a checkedListbox based on its value. I 'm getting a number(say 1355) from another control and based on that number I want to check an item which its value is 1355,how can I do that? thannks.
1
1587
by: Hrvoje Voda | last post by:
I have a users name in checkedlistBox and usersID in listBox. How to connect those to lists to get a userID from listBox depending on userName from checkedlistBox? Hrcko
1
6005
by: xiuyu_0129 | last post by:
Hi All, How do I store a string value for an item in a CheckedListBox in Windows Form? For a web based application, CheckBoxList allowed us to store 2 string values for the item in it. How do I achieve that when making use of the CheckedListBox in windows form. Thanks.
4
3778
by: Matthew | last post by:
Hi, I am using a checkedlistbox on a windows form and binding it to a collection of classes. clbAliases is the checkedlistbox control selectedplace is a class with property placealiases.This property is a collection of placealias classes. Hopefully the rest is self-explanatory..
8
1789
by: Derek Martin | last post by:
Here is some code that I need help with please: Dim result As New ArrayList Try For i = 0 To objecttest1.PersonList.person_returnnumber - 1 result = objecttest1.PersonList.time_returnpunches(objecttest1.PersonList.person_getb yid(i).userid, "03/08/2004", "03/09/2004", True, False) 'The above line returns an object with several proerties,...
2
2275
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...
9
8491
by: Capt_Ron | last post by:
Hello, I would like to set the value of the item in the checked list box. I have a datareader that has 2 columns. PK and TEXT I want the TEXT as the Item and the PK as the Value. I can not find anywhere that I can SET the value. But I can GET the SELECTED ITEM VALUE. Any direction would be helpfull.
5
6846
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...
6
6926
by: Steve Teeples | last post by:
Can someone show me an example of how to place a "CheckedListBox" property within a PropertyGrid? -- ----------- Thanks, Steve
0
7693
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
7916
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. ...
1
7660
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...
1
5498
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
3651
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...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2101
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
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
932
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...

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.