how to link a radio button to a command button? (mfc c++)
-
good day, here is my problem on how to link the commandbutton to radio buttons (mfc) in c++: i inserted 3 radiobuttons inside a groupbox with a caption "Mode of payments"; radio1 with a caption "1. Cash (10% discount)"; radio2 with a caption "2. Two payments (5 % interest)"; radio3 with a caption "3. Three payments (10% interest); i also have two editboxes; editbox1 and editbox2. 1. with a static text "enter tuition fee:" value will be accepted in the first editbox. 2. with a static text "Your total tuition fee is:" will be displayed in the second editbox. and one command button with a caption "Compute" supposing i will select the second radio button which is "two payments (5% interest)" upon clicking the command button "compute" the result should be displayed in the second editbox under "your total tuition fee:" which is the computation on the value of the first editbox and on the second radiobutton and so on... if i will not use a commandbutton "compute" caption (to do the calculation) i can do the code and get the right result by calculating the value of the first editbox and on the radiobutton values, but when i will use commandbutton to do the calculation on the value of the first editbox to the radiobuttons that is now my problem since i cannot link the radiobuttons and the commandbutton... Please anybody help me in solving this problem...i need sample code as guide in solving this problem and on my future related projects... code experts please help me... thank again and thank you in advance... neil
-
good day, here is my problem on how to link the commandbutton to radio buttons (mfc) in c++: i inserted 3 radiobuttons inside a groupbox with a caption "Mode of payments"; radio1 with a caption "1. Cash (10% discount)"; radio2 with a caption "2. Two payments (5 % interest)"; radio3 with a caption "3. Three payments (10% interest); i also have two editboxes; editbox1 and editbox2. 1. with a static text "enter tuition fee:" value will be accepted in the first editbox. 2. with a static text "Your total tuition fee is:" will be displayed in the second editbox. and one command button with a caption "Compute" supposing i will select the second radio button which is "two payments (5% interest)" upon clicking the command button "compute" the result should be displayed in the second editbox under "your total tuition fee:" which is the computation on the value of the first editbox and on the second radiobutton and so on... if i will not use a commandbutton "compute" caption (to do the calculation) i can do the code and get the right result by calculating the value of the first editbox and on the radiobutton values, but when i will use commandbutton to do the calculation on the value of the first editbox to the radiobuttons that is now my problem since i cannot link the radiobuttons and the commandbutton... Please anybody help me in solving this problem...i need sample code as guide in solving this problem and on my future related projects... code experts please help me... thank again and thank you in advance... neil
Could you please restate more clearly what it is you want to do? Do you want it to calculate the answer without having to click on the button?
-
Could you please restate more clearly what it is you want to do? Do you want it to calculate the answer without having to click on the button?
i will select first on one of the radio buttons then by clicking on the command button which has a caption "compute" c++ will give an answer and it will be displayed in the second editbox.
-
i will select first on one of the radio buttons then by clicking on the command button which has a caption "compute" c++ will give an answer and it will be displayed in the second editbox.
So you want it to give a different answer depending upon which radio button is chosen?
-
So you want it to give a different answer depending upon which radio button is chosen?
yes sir if supposing i will select the first radio button which is "cash (10 % discount)" the calculated amount is the amount of the "enter tuition fee editbox1" * .90 since 10% will be deducted to the tuition fee. If radiobutton2 is selected "two payments (5% interest)" the calculated amount is the amount of the "enter tuition fee editbox1" + 5% interest. Please sir help me on this problem. neil
-
yes sir if supposing i will select the first radio button which is "cash (10 % discount)" the calculated amount is the amount of the "enter tuition fee editbox1" * .90 since 10% will be deducted to the tuition fee. If radiobutton2 is selected "two payments (5% interest)" the calculated amount is the amount of the "enter tuition fee editbox1" + 5% interest. Please sir help me on this problem. neil
All you have to do is use the GetCheck() function:
if ( radiobutton1.GetCheck() == BST_CHECKED )
{
// First radio button chosen
}if ( radiobutton2.GetCheck() == BST_CHECKED )
{
// Second radio button chosen
} -
All you have to do is use the GetCheck() function:
if ( radiobutton1.GetCheck() == BST_CHECKED )
{
// First radio button chosen
}if ( radiobutton2.GetCheck() == BST_CHECKED )
{
// Second radio button chosen
}i will try this one sir...thank you very much for the help neil
-
All you have to do is use the GetCheck() function:
if ( radiobutton1.GetCheck() == BST_CHECKED )
{
// First radio button chosen
}if ( radiobutton2.GetCheck() == BST_CHECKED )
{
// Second radio button chosen
}<big>thank you very much</big> chard your code solve my problem. I posted this problem because i dont have the sample code on how to connect the radiobutton to the command button. Spider and chandru never gave me the sample code to solve my problem. here is now my code in c++ void CTuition1Dlg::OnButton1() { // TODO: Add your control notification handler code here UpdateData(); if ( m_button1.GetCheck() == BST_CHECKED ) { m_edit2 = m_edit1 * .9; UpdateData(false); } if ( m_button2.GetCheck() == BST_CHECKED ) { double x; x = m_edit1 * .05; m_edit2 = m_edit1 + x; UpdateData(false); } if ( m_button3.GetCheck() == BST_CHECKED ) { double x; x = m_edit1 * .10; m_edit2 = m_edit1 + x; UpdateData(false); } UpdateData(false); } if its not for your code I cannot solve it...thank you very much do you have ym sir chard? i would like to ym you if i have a problem on programming and i wish that you will still help me. Once again thank you... neil