We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Overriding a function

Thread ID:





1659 Nov 18,2002 01:21 PM Dec 7,2002 05:26 PM Windows Forms 2
Tags: FAQ
Asked On November 18, 2002 01:21 PM

Hi- 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! Thanks, Aryana

Replied On November 19, 2002 07:01 AM

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. Thanks, Aryana

Administrator [Syncfusion]
Replied On 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


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.