Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Strange Listview behaviour
Message
From
20/07/2006 15:50:08
 
General information
Forum:
ASP.NET
Category:
Forms
Miscellaneous
Thread ID:
01138022
Message ID:
01138203
Views:
14
Dunno what's going on, Pete ... it should work (I just tested it in VS2005). You're not showing all your code there (no clue at what point you're adding the lvItem to the actual ListView), so maybe you can post a little more of the code and we can figure it out.

I would think you'd want something like this:
ListViewItem item;

foreach (DataRow dr in this.dsClaims.Tables[0].Rows)
{
    lvItem = new ListViewItem(dr["PayDetailsConf"].ToString());
    lvItem.Text = "";
    lvItem.Checked = (bool)(dr["PayDetailsConf"]);

    // I added this next line:
    this.MyListView.Items.Add(lvItem);
}
Although, if you didn't have that extra line in your original code, I don't know how it would have worked in VS2003 either. <g>

Oh, one other strange thing ... why are you blanking out the .Text after you create the ListViewItem? If you didn't want any text in the lvItem, all you had to do is instantiate it without any parameters:
    lvItem = new ListViewItem();
~~Bonnie



>Hello All, the code below used to work with VS 2003 ! but it doesn't in VS 2005. I'm sure you all know what the code is doing but I'll run through it anyway, when I'm loading the lv I check to see if a field in a datarow has a value of 1 (and cast it to a bool ) , and if so, check the item. Whats happening with VS 2005 is, only the first item in the list is being checked ! (read - checkbox is being checked ), anyone know why ?
>
>
>
>
>
>ListViewItem item;
>
>foreach (DataRow dr in this.dsClaims.Tables[0].Rows)
>{
>    lvItem = new ListViewItem(dr["PayDetailsConf"].ToString());
>    lvItem.Text = "";
>    lvItem.Checked = (bool)(dr["PayDetailsConf"]);
>}
>
>
>regards
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform