If i' having three radio button and want to generate event on clicking or checking of any radio button accordingly
how Radio button can be combined with if else
Collapse
X
-
Create an event handler in your code... the easiest way to do this is to select a radio button, go to the events page (lightning bolt in properties pane), and double-click CheckChanged.
This will automatically create an event handle for you with the signature...
It's important to know here that sender, while of type object, is actually the radio button that sent the event. If you cast sender to a RadioButton object, you can use it.Code:private void SOMEMETHODNAME(object sender, EventArgs e) ...
Now you can go to the events pane for the other radio buttons and click the dropdown for the CheckChanged event and select the method.Code:RadioButton senderRB = sender as RadioButton; if (senderRB != null) { MessageBox.Show(senderRB.Text + " clicked!"); }
In this fashion, a single event handler can be used to handle events on multiple objects.
I'm not entirely sure that's what you were looking for, but hopefully it helps. You can do similar for a RadioButton's Click event. -
radio button and combobox
i'm using 3 radio button and a combobox and 4 textboxes.
each time aradio button is clicked combobox vaues are changing and on selecting combox textboxes values are changing,i'm using array list concept to retrieve data from Access database.
But it is working only for the radiobutton which is clicked first on second click of other radio button it is showng "Object reference not set to an instance of an object." in splitstr = this.strArrayli st[this.comboBox1. SelectedIndex].Split(delimete r, 5);Comment
-
Using Visual Studio, set a breakpoint at that line. Try to identify which object is null. It's entirely possible that the combobox doesn't have a selected index (thus it would be -1) and you're trying to call a Split on a null string.
How are you selecting the combobox item when the radio button is pressed?
If you require further help, I think you'll need to post some code so we can see what's going on.Comment
Comment