﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » Conditionally add checkbox to a row in a listview</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Sun, 26 Jul 2026 21:10:55 GMT</lastBuildDate><ttl>20</ttl><item><title>Conditionally add checkbox to a row in a listview</title><link>http://forum.strataframe.net/FindPost25066.aspx</link><description>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.  &lt;br&gt;
&lt;br&gt;
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.&lt;br&gt;
&lt;br&gt;
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.  ?&lt;br&gt;
&lt;br&gt;
In order to do this, do I need to populated the listview manually or can I still do a copydatafrom ?&lt;br&gt;
&lt;br&gt;
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 )&lt;br&gt;
&lt;br&gt;
Any thoughts appreciated,  very much under the gun on this :w00t:&lt;br&gt;</description><pubDate>Fri, 30 Oct 2009 11:39:53 GMT</pubDate><dc:creator>Charles R Hankey</dc:creator></item><item><title>RE: Conditionally add checkbox to a row in a listview</title><link>http://forum.strataframe.net/FindPost25076.aspx</link><description>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.&lt;br&gt;
&lt;br&gt;
But next week I'll retrofit this with a Stratalistview.&lt;br&gt;
&lt;br&gt;
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! :D  )&lt;br&gt;</description><pubDate>Fri, 30 Oct 2009 11:39:53 GMT</pubDate><dc:creator>Charles R Hankey</dc:creator></item><item><title>RE: Conditionally add checkbox to a row in a listview</title><link>http://forum.strataframe.net/FindPost25072.aspx</link><description>Hi Charles,&lt;br&gt;
&lt;br&gt;
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:&lt;br&gt;
[quote]&lt;br&gt;
    Private Sub lstPayments_ItemChecked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ItemCheckedEventArgs) Handles lstPayments.ItemChecked&lt;br&gt;
        If Me.bizPayments_Daily.PaymentStatus = Enumerations.PaymentStatus.Paid Then&lt;br&gt;
            If e.Item.Checked = False Then&lt;br&gt;
                e.Item.Checked = True&lt;br&gt;
            End If&lt;br&gt;
        End If&lt;br&gt;
    End Sub&lt;br&gt;
[/quote]&lt;br&gt;
&lt;br&gt;
Of course you can do it in a single line like e.Item.Checked = MyBO.RequiredConditionField = True&lt;br&gt;
&lt;br&gt;</description><pubDate>Fri, 30 Oct 2009 10:24:16 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Conditionally add checkbox to a row in a listview</title><link>http://forum.strataframe.net/FindPost25067.aspx</link><description>[quote]want to handle this in one listview, can I conditionally have a checkbox only on the optional rows??[/quote]&lt;br&gt;
&lt;br&gt;
On the new StrataListView, yes.  Inherited and enhance list SF ListView, no.&lt;br&gt;
&lt;br&gt;
[quote]&lt;br&gt;
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 )[/quote]&lt;br&gt;
&lt;br&gt;
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.&lt;br&gt;
&lt;br&gt;
[codesnippet]foreach(StrataListViewItem i in sfListView.GetCheckedItems(1))&lt;br&gt;
{&lt;br&gt;
    //-- 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&lt;br&gt;
}[/codesnippet]</description><pubDate>Fri, 30 Oct 2009 08:48:24 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>