Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

How to write code inside a programmatically created control and its event ?

$
0
0
int locy = 41;
            for (int i = 0; i < hdcount; i++)
            {
                RadioButton rdbtn = new RadioButton();
                rdbtn.Name = "rdbtn" + i.ToString();
                rdbtn.Location = new System.Drawing.Point(12, locy);
                rdbtn.Enabled = false;
                this.Controls.Add(rdbtn);
                locy += 23;

                rdbtn.CheckedChanged += new         EventHandler(rdbtn_CheckedChanged); 
            }

The last line of code. it makes a new event handler for radio button checked changed event. 

And I want to know how can I make this program add some code inside the programmatically generated eventhandlers programmatically ?

I need to add "button3.Enabled = true;" code in all the radiobutton CheckedChanged events programatically.

How can I do this ?


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>