radiobutton and bool
-
HI, I have two radio buttons male and female in windows form.... this is my code..... whatever i do it will only display female which ever radio button i clicked.... i suspect there is some pblm with my bool... can anybody help me plzzz bool flag=true; public Form1() { InitializeComponent(); } private void txtBranch_TextChanged(object sender, EventArgs e) { } private void btnRadio_Click(object sender, EventArgs e) { if (flag==true) { txtBranch.Text = rdoMale.Text; } if(flag==false) { txtBranch.Text = rdoFemale.Text; } } } } thanks in advance
C#
-
HI, I have two radio buttons male and female in windows form.... this is my code..... whatever i do it will only display female which ever radio button i clicked.... i suspect there is some pblm with my bool... can anybody help me plzzz bool flag=true; public Form1() { InitializeComponent(); } private void txtBranch_TextChanged(object sender, EventArgs e) { } private void btnRadio_Click(object sender, EventArgs e) { if (flag==true) { txtBranch.Text = rdoMale.Text; } if(flag==false) { txtBranch.Text = rdoFemale.Text; } } } } thanks in advance
C#
kabutar wrote:
if(flag==false) { txtBranch.Text = rdoFemale.Text; }
You are not setting flag=false anywhere in the code
-
HI, I have two radio buttons male and female in windows form.... this is my code..... whatever i do it will only display female which ever radio button i clicked.... i suspect there is some pblm with my bool... can anybody help me plzzz bool flag=true; public Form1() { InitializeComponent(); } private void txtBranch_TextChanged(object sender, EventArgs e) { } private void btnRadio_Click(object sender, EventArgs e) { if (flag==true) { txtBranch.Text = rdoMale.Text; } if(flag==false) { txtBranch.Text = rdoFemale.Text; } } } } thanks in advance
C#
if you have two radio buttons then btnRadio_Click(object sender, EventArgs e) corresponds to which radio button is it for both ?
Koushik
-
kabutar wrote:
if(flag==false) { txtBranch.Text = rdoFemale.Text; }
You are not setting flag=false anywhere in the code
but navneeth isnt the bools default value always false.....? can you just alter my complete code for me so that i can understand it better if you dont mind.... or is there anyother way of doing by not using the bool ie something like if(rdobuttonmale.selected) { txtBranch.Text = rdoMale.Text; } if(rdobuttonfemale.selected) { txtBranch.Text = rdoFemale.Text; } my basic purpose is the same ie the textbox should display the selected radio button....:) thanking you
C#
-
but navneeth isnt the bools default value always false.....? can you just alter my complete code for me so that i can understand it better if you dont mind.... or is there anyother way of doing by not using the bool ie something like if(rdobuttonmale.selected) { txtBranch.Text = rdoMale.Text; } if(rdobuttonfemale.selected) { txtBranch.Text = rdoFemale.Text; } my basic purpose is the same ie the textbox should display the selected radio button....:) thanking you
C#
But I see only one event here. Write two events for both radio buttons, and assign the textbox value in those events. No need of using the flag
-
But I see only one event here. Write two events for both radio buttons, and assign the textbox value in those events. No need of using the flag
-
hi, i have one more doubt if i want to use multiple windows that form1 will have datagrid and form2 will have textboxes and if i want to display the details entered in form2 in the datagrid in form1 .....do i need to use delegates or is there any other easy way of doing it..... :) thanks
C#
-
hi, i have one more doubt if i want to use multiple windows that form1 will have datagrid and form2 will have textboxes and if i want to display the details entered in form2 in the datagrid in form1 .....do i need to use delegates or is there any other easy way of doing it..... :) thanks
C#
kabutar wrote:
do i need to use delegates or is there any other easy way of doing it.....
Delegates are always a good practice. Alternatively you can overload form2 constructor and pass form1 object there while invoking form2. Use this object to set value back to form1.
-
kabutar wrote:
do i need to use delegates or is there any other easy way of doing it.....
Delegates are always a good practice. Alternatively you can overload form2 constructor and pass form1 object there while invoking form2. Use this object to set value back to form1.