How to get/set checkboxes in a listview control?

656 views
Skip to first unread message

DrDedichen

unread,
Mar 14, 2013, 7:24:01 AM3/14/13
to teststa...@googlegroups.com
I haven't found a way to read the checked/unchecked-status for a row in a asp.net-listview with checkboxes. Checking/unchecking can be done by doubleclicking the row, but it would be better to be able to check or uncheck. Any way to do this?

Jake Ginnivan

unread,
Mar 14, 2013, 7:25:51 AM3/14/13
to DrDedichen, teststa...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "TestStack.White" group.
To unsubscribe from this group and stop receiving emails from it, send an email to teststack_whi...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

DrDedichen

unread,
Mar 14, 2013, 7:32:37 AM3/14/13
to teststa...@googlegroups.com, DrDedichen
Sorry my bad, not asp.net. I meant Winform

I use following code to check the checkbox at a line at the moment:

foreach (ListViewRow listViewRow in MyListView.Rows)
                {
                    if (value.Contains(listViewRow.Cells[1].Text))
                    {
                        listViewRow.DoubleClick();

DrDedichen

unread,
Mar 14, 2013, 7:37:49 AM3/14/13
to teststa...@googlegroups.com
This is example in the production code for setting checked status for all rows in listview based on a select all checkbox. Then the ListViewItem has a Checked-property. How can I access this using White?

foreach (ListViewItem listViewItem in lViewTags.Items)
            {
                listViewItem.Checked = cBoxSelectAll.Checked;

Jake Ginnivan

unread,
Mar 18, 2013, 8:59:45 PM3/18/13
to Anders Kløven, teststa...@googlegroups.com

In that case maybe use ‘var comboBoxes = listView.AsContainer().GetMultiple(SearchCriteria.ByControlType(ControlType.ComboBox)).OfType<ComboBox>();’

 

Or listItem.AsContainer().Get<ComboBox>();

 

Let me know of that helps.

 

Cheers,

Jake

 

From: Anders Kløven [mailto:akl...@gmail.com]
Sent: Monday, March 18, 2013 7:20 PM
To: Jake Ginnivan
Subject: Re: How to get/set checkboxes in a listview control?

 

Hi, thanks for the feedback. I am not using a ListBox, but a ListView with the property CheckBoxes set to true.

Regards,
Anders

--

Reply all
Reply to author
Forward
0 new messages