-
March 16th, 2012, 01:57 PM
#1
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!
-
March 17th, 2012, 07:39 PM
#2
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?
Last edited by Cimperiali; March 17th, 2012 at 07:51 PM.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
March 18th, 2012, 02:47 PM
#3
Re: Assign checkBoxes values to clicked radiobutton
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
Last edited by JonnyPoet; March 18th, 2012 at 02:56 PM.
Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
-
March 19th, 2012, 09:02 AM
#4
Re: Assign checkBoxes values to clicked radiobutton
Thank you very much sir. How was the weekend? I'll do as you instructively advised.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|