I have created radio buttons at run time to select a particular file to access. The code is:
The radio buttons are properly created and all use the rb_clicked event handler. What I want to do is to extract the text associated with the button that was clicked. If I look at sender in the debugger the text is there but I don't know how to extract it.Code:System.Windows.Forms.RadioButton[] rb = new System.Windows.Forms.RadioButton[fileNamesSaved]; for (int i =0; i < fileNamesSaved; i++) { rb[i] = new RadioButton(); rb[i].Text = fileNames[i]; rb[i].Location = new System.Drawing.Point(10, 10+i * 20); rb[i].Click += new EventHandler(rb_clicked); this.Controls.Add(rb[i]); } test = 0; } private void ReturnToBaseForm_Click(object sender, EventArgs e) { Form1 f1 = new BaseForm.Form1(); this.Hide(); f1.ShowDialog(); } private void rb_clicked(object sender, EventArgs e) { // need something in here to get the text associated with the particular button that was clicked. }
I appreciate any help - have tried a number of possible way to do this but none of them worked




Reply With Quote
