Assign checkBoxes values to clicked radiobutton
Code:
class LinkWindow{
public void linkUser_Click(object sender, EventArgs e)
{
AllUsers all = new AllUsers();
all.Show();
if(personPanel.Controls!=null){
foreach(Control items in personPanel.Controls){
Insert ins = new Insert();
ins.InsertMe();
}
}
}
}
____________________________________________________________________________
public class Insert : Linkwindow{
int checkBoxCount = 0;
public void InsertMe() {
if (rolePanel.Controls != null)
{
Control control = new Control();
if (control.GetType() == typeof(CheckBox))
{
if (((CheckBox)control).Checked == true)
{
foreach (CheckBox checkes in rolePanel.Controls)
{
checkBoxCount++;
}
}
}
}
}
}
Please this code compile well but not doing what I expected. What i want to do is that when I click a radiobutton, check some checkboxes and click linkUser button it should display the checkboxes on the AllUsers form. I did not get it right, I know. Please help a newbie!
Re: Assign checkBoxes values to clicked radiobutton
The code you showed is not that linear: you have a base class, and a class that inherits from it, plus a couple of panel, a bounch of radio and the requirement to check checkboxes and show them on a "AllUsers" form.
That could be really easy to do, but you showed a base class that create instances of a derived class, and both cycle thorugh controls on Panels.
I did not see code to handle the radioButtons click, nor code to check checkbokes, but only code to count already checked ones.
In conclusion, if you want someone here to help you, you should show code more related to your request or explain better what you have (why those two classes?Which is the idea behind?) and were are you bloked (you really need to know how to check a checkbox via code? Or you need to understand something else?) .
By the way, why not at least add a small screenshot of how your form(s) should look like? And add some of the rules (or we could give you a sample of a click on a radio and a consequently checking of random checkboxes?)
in any case,you should handle somewhere the click event on a radiobutton. That means somewhere in your code (probably after the Initializecomponent) you should have something like
Code:
this.radioButton1.CheckedChanged += new System.EventHandler(this.rd_CheckedChanged);
and a routine like
Code:
private void rd_CheckedChanged(object sender, EventArgs e)
{
//here you should "check" the appropriate checkboxes
}
in a similar way, you should have an handler to the click of the button. And in the routine that handle it you shoudl prepare and show your "AllUser" forn
But really this is what you were looking for here?
Re: Assign checkBoxes values to clicked radiobutton
Quote:
Originally Posted by
ken4ward
Please this code compile well but not doing what I expected. What i want to do is that when I click a radiobutton, check some checkboxes and click linkUser button it should display the checkboxes on the AllUsers form. I did not get it right, I know. Please help a newbie!
Like already Cimperiali told you there is more to be known about that to help you. For giving you correct advice I wanted to see that codeparts where you are actually working on. But what I got is nothing which shows any of that lines you are showing here in forum. You need to add exactly that controls you are just working on.
Sww his posts here
http://www.codeguru.com/forum/showth...01#post2060701
Its regarding the same application
Re: Assign checkBoxes values to clicked radiobutton
Thank you very much sir. How was the weekend? I'll do as you instructively advised.