Conditionally add checkbox to a row in a listview


Author
Message
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Need some help clarifying my thinking. i am presenting the user with a listview of PDFForms. They are loaded from a BO. Bo.PDFstatus determines if this PDF is optional - i.e. user can select it - while all others are included by default and cannot be unincluded.



I have a PDFSelected boolean (bit) field in the PDFbo. When the user gets done with the list I want to process all the PDFs from this BO, including any that are selected in the list and all those that are required.



If I want to handle this in one listview, can I conditionally have a checkbox only on the optional rows?? Should that be added somehow in rowpopulating and should they be attached to the PDFSelected or to the PDFName - first column of list. ?



In order to do this, do I need to populated the listview manually or can I still do a copydatafrom ?



I know how to updatae PDFBO from the listview selection once choices are made (that's why I'm not using new Stratalistview as there doesn't seem to be SelectedIndex expose )



Any thoughts appreciated, very much under the gun on this w00t

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
want to handle this in one listview, can I conditionally have a checkbox only on the optional rows??




On the new StrataListView, yes. Inherited and enhance list SF ListView, no.





I know how to updatae PDFBO from the listview selection once choices are made (that's why I'm not using new Stratalistview as there doesn't seem to be SelectedIndex expose )




Sure there is. I had a conversation with Greg through PM the other day and he was really wanting a SelectedIndices collection to be exposed. And though I will add this so people can retro fit code more easily, you don't need it. In the case of a checked list item on the new StrataListView, just call the GetCheckedItems() method and supply the column from which you are trying to get the checked items. It will return a collection of all of the items checked within that column without the need to deal with any index positioning or manualy enoerating the list.



foreach(StrataListViewItem i in sfListView.GetCheckedItems(1))

{

//-- It will return the full row, not just the sub-item. But only items with the checked box selected in the 2nd column in this example, will be returned

}

Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Charles,



If you are using the current Listview, you could also handle the ItemChecked event and validate it so if the user uncheck a required item, you simply check it again, here is a sample:



Private Sub lstPayments_ItemChecked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ItemCheckedEventArgs) Handles lstPayments.ItemChecked

If Me.bizPayments_Daily.PaymentStatus = Enumerations.PaymentStatus.Paid Then

If e.Item.Checked = False Then

e.Item.Checked = True

End If

End If

End Sub





Of course you can do it in a single line like e.Item.Checked = MyBO.RequiredConditionField = True




Edhy Rijo

Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)Advanced StrataFrame User (922 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Thanks guys. I think today I will use Edhy's approach, just because the list is already a standard list view and I can give everyone a checkbox and then kill the click for those that are required and checked by default.



But next week I'll retrofit this with a Stratalistview.



Trent, I think Greg's issue was using the code you gave me for moving rows, which works quite well with listview but chokes in Stratalistview singe SelectedIndex(0) doesn't seem to be a meaningful concept. could you give an example of doing that row moving thing with Stratalistview ( which, once again, is VERY COOL! BigGrin )

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