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

Recommended Answers

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

Jump to Post

All 6 Replies

Re: select value from check box 80 80

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

commented: good suggestion +5
Re: select value from check box 80 80

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());
            }
Re: select value from check box 80 80

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!

Re: select value from check box 80 80

Hey
Thanks to all.

Re: select value from check box 80 80

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

Re: select value from check box 80 80

Please mark this thread as solved, if your problem is solved.......
Thank you..

Be a part of the DaniWeb community

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