0

hi,
pls. tell me how to select value from a check box, & from a list box or combo box.
actually i m new to c# , so sorry for this stupid question but i need your help.
Thanx in advance.
Happy Diwali
Regards
~ Dimple

6
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by avirag
Featured Replies
  • 1
    __avd 1,826   7 Years Ago

    For checkBox, use [b]Checked[/b] and [b]CheckState[/b] property. List and ComboBox; use [b]SelectedValue[/b] property. Read More

  • It wasn't clear to me whether your question was for obtaining the state, as you have already been directed, or you are wanting to set the state, which I will throw out some additional direction below. [code=csharp] // ListBox method to select an item... public void SetSelected(int index, bool value); … Read More

  • how to gridview selected checkbox row send (pass) to same sqldatabase Read More

1

For checkBox, use Checked and CheckState property.
List and ComboBox; use SelectedValue property.

Comments
good suggestion
0

The example below will retrieve the value of a checkbox and display it in a messagebox on a button click event.

if (checkBox1.Checked)
            {
                MessageBox.Show(checkBox1.Text.ToString());
            }
1

It wasn't clear to me whether your question was for obtaining the state, as you have already been directed, or you are wanting to set the state, which I will throw out some additional direction below.

// ListBox method to select an item...
public void SetSelected(int index, bool value);
public ListBox.SelectedObjectCollection SelectedItems { get; } // to see all items selected...
// and, to capture when the selection is changing:
public event EventHandler SelectedIndexChanged;

// RadioButton method to get/set state:
public bool Checked { get; set; }
// and, to capture when the state has been changed:
public event EventHandler CheckedChanged;

// ComboBox methods to select item:
public override int SelectedIndex { get; set; }
public object SelectedItem { get; set; }
// and, to capture when the selection has changed:
public event EventHandler SelectedIndexChanged;

If you search on these, you should be able to find all the example code you need to see/understand how these are implemented in a form.

Cheers!

Edited by DdoubleD: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.