Hi i m new in c#.
i want to my button enable when i select any item in list box.
i m able to do it but when i deselect all the items in listbox so my button is still enable.i want to disable now when no item is selected in list box..
Regards...
Farhad Idrees

private void listBox1_SelectedIndexChanged(object sender, EventArgs e) {
    if (listBox1.SelectedIndices.Count > 0) {
        button1.Enabled = true;
    } else {
        button1.Enabled = false;
    }
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) {
    if (listBox1.SelectedIndices.Count > 0) {
        button1.Enabled = true;
    } else {
        button1.Enabled = false;
    }
}

thanks man it's working well

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.