Can anyone help me on how can I disabled specific rows in ListView using vb.net 2003 language?
A:
Not sure what you mean with disable.
You can't enable/disable ListViewItems but depending on what you want to do you can fake it in various ways. For example you can handle the ListView.SelectedIndexChanged event and unselect the items you didn't want the user to select. Possibly would need to combine that with changing the backcolor/forecolor of the items to make them look unselected again.
However, if you're able to use a different control, it might be worth considering a DataGridView instead of a ListView, it can be little more difficult to get started with but if you're going to be doing more advanced stuff than just showing a list it might be a lot easier.
ho1
2010-04-20 04:40:13
Can you tell me on how can I change the backcolor/forecolor of the items?
Mark
2010-04-20 04:45:10
I got it. Thanks anyway :D
Mark
2010-04-20 04:48:40
Im back again :DI got to do changing of backcolor of the specific row of listview but I don't know how can I validate it.if the user clicked or selected the rows with background color of red then the messagebox will appear and prompt the user that it can't be selected.
Mark
2010-04-20 04:56:01
In the same SelectedIndexChanged Event, check if the color is red. If yes, set the selectedItem to the previousItem and display a msg.
Veer
2010-04-20 05:05:53
Is it the right code?If lvManualEntry.SelectedItems(0).BackColor = Color.Red Then 'Do EventsEnd If
Mark
2010-04-20 05:13:47
Should work. However, unless you use the tag of the ListViewItem for something else, I'd suggest storing some value in there that says if it's disabled or not. So for example, when you create all items, set the tag to True and then set to False for disabled items. Feels nicer to me than having the logic depend on the colour.
ho1
2010-04-20 07:00:13