Ok so here is my problem:
I have a windows form that displays a certain number of user controls based on some user input. The user control is composed of 4 radio buttons. So for example let’s say that based on the user’s input 3 user controls will be displayed. The first user control (user control 1) will have the radio button’s text based on the user input. Now what I want to have happen is based on the radio button selection the user makes in user control 1, the next user control’s (user control 2) radio button’s text property will be displayed. And then based on the selection the user makes in user control 2, user control three’s radio button text properties will be displayed.
I am having a lot of trouble doing this. If I just use the CheckChanged events raised by each of the radio buttons, it only changes the text for that particular user control and not the following user control. What I am wondering is there a way I can override the checkChanged event for each of the user controls with code in my form. Does this make any sense? Is there a better way to do what I want to do? I am trying to use delegates and events but I can’t seem to get the code right and doing what I want to do. If anyone could help I would be extremely greatful!
Ok so I have figure out what I need to do but am not sure how to write the code to do that. What I want to do is create an event on my user control that is fired whenever any of the CheckChanged events from any of the radio buttons occur. Then I want to write an event handler in your form.
So in my user control I declare a delegate and then an event of that delegate type:
public delegate void EventHandler(object sender, System.EventArgs e); (this is outside of the user control class)
public event EventHandler CheckedChanged;
But now I am not sure what to do. I am not sure how to call that the event in the CheckedChanged event of each of the radio buttons. And then I don't really know how to deal with that in the form. If anyone could help me out, that would be great.
ADAdministrator Syncfusion Team December 7, 2002 05:26 PM
u dont have to write ur own delegate at all
do it like this:
u first write the general click event which u wish to handle all events from all radioButtons ,lets say radioButton1_Click.
then in the code editor ull see a region entitled
"Windows form designer generated code".Expand it and add following to the code:
this.radioButton1.Click += new System.EventHandler(this.radioButton1_Click);
similarly attached all the click events handler to the same one ,here is this.radioButton1_Click
this.radioButton2.Click += new System.EventHandler(this.radioButton1_Click);
this.radioButton3.Click += new System.EventHandler(this.radioButton1_Click);
and so on