Reputation: 29
If you type a word on the "txtProdBarcode" section, the lists will come at the bottom like the picture. The list sections name is "lvBase" which is aListView
.
Then when you type a word on the "searchText" section, the checkboxes on the "lvBase" section shouldn't be clickable. I don't want to remove the checkboxes, but want to prevent them from being checked.
I've tried my best but can't get the answer.
private void txtProdBarcode_TextChanged(object sender, EventArgs e)
{
string searchText = txtProdBarcode.Text.ToUpper().Trim();
if (searchText.Length > 0)
{
lvBase.CheckBoxes = false;
}
else
{
lvBase.CheckBoxes = true;
}
This code deletes the checkboxes on the "lvBase" section.
But I want only the checkboxes to be disabled.
Can you guys help me to solve this problem?
Upvotes: 2
Views: 566
Reputation: 125197
To prevent checking items of ListView
, you can handle ItemCheck
event:
bool preventCheck = true;
private void listView1_ItemCheck(object sender, ItemCheckEventArgs e)
{
if (preventCheck) // for example: !string.IsNullOrEmpty(textBox1.Text)
e.NewValue = e.CurrentValue;
}
Upvotes: 3