checked listbox question


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
This is just standard ListView behavior and we do not add any additional functionality here.  But to use a checked list view, just set the CheckBoxes property to True.  Then to set a ListView checked item it would just be setting the Checked property of the ListVIew item.

MyListView.Items(0).Checked = True

You can also referenced the CheckedItems collection to see which items have been checked rather than having to cycle through the Items collection and testing:

Dim loItem As ListViewItem

For Each loItem IN MyListView.CheckedItems
    '-- Place your code here to do something with the checked item
Next


Keith Chisarik
Keith Chisarik
StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)
Group: StrataFrame Users
Posts: 939, Visits: 40K
I got it, its just like ListView pretty much with a CheckedItems collection.....




Keith Chisarik
Keith Chisarik
Keith Chisarik
StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)
Group: StrataFrame Users
Posts: 939, Visits: 40K
Any examples or sample code for checked listview control around?



I checked the documentation but all it seems to have is member/property definitions.



I checked the sample apps and could not find anything.



All I want to do is populate the listview from a single table/colum and allow the user to select some. I don't want it bound back to the table, so if I can just read the "checked" selections and be done that is the desire. Does it try to persist the values back to a field in your datasource? I can only imagine it does since it uses PopulationDataSourceSettings.....




Keith Chisarik
StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
It's OK to drive on the wrong side of the road sometimes... just as long as your steering wheel is still on the correct side and you don't have to shift with your left hand Smile
Paul Chase
Paul Chase
Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
Thanks Ben that helps alot. I was driving on the wrong side of the road againSmile

P

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
You'll want to select all of the items from the JsEquipment table and populate the checked list box off of that.  When you build the list, you'll want to do one of 2 things:

1) do a left join of the JsEquipment on the link table so that you can tell what should be checked (if the field is NULL then it should be unchecked, otherwise, it should be checked)

2) you can add all of the nodes to a dictionary (System.Collections.Generic.Dictionary(Of Guid, TreeNode)) so you can access all of the tree nodes later by their primary key.  After you have the list populated, you will then need to be set the checked state on the nodes to their initial state... that's why you need the dictionary.  Do a join on the link table and cycle through the returned records calling TreeView.SetNodeState(Dictionary(LinkBO.EquipmentFK), True) to check them.

When you want to set the state of a node, you can use SetNodeState(node, true/false), which will set the checked state of the parent/child nodes as well.  Don't forget to store off the GuidPK of the piece of equipment in the tag of the node.

Once you have the list populated, you can use the NodeStateChanged event handler... do a .Seek() within the link table and either add or remove a record from the link table depending upon whether the node is checked or unchecked.

Paul Chase
Paul Chase
Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
I cannot seem to get this right but it has been a long weekSmile

I have 3 tables

Jobsite - contains info about a job

Equipment - contains a list of equipment (shovels,hard hats etc)

JsEquipment link table for first 2 tables contains a Pk and 2 FK's from each above tables JSE_PK,JBS_FK,EQP_FK

I want to use a checked listbox to allow the user to select which equipment needs to be used on the job. Can you give me a rundown on how to set up the checked listbox. I have tried but failed..BigGrin By the way all the primary and foreign keys are guid's

Thanks

P

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search