Hello,
I have a form with Checkbox style buttons. Is there a way to find this specific kind of button?
When I am using:
m_MessageBox = Application.FindFormTitle(formName);
m_ButtonLeft = m_MessageBox.FindButton("btnLeft");
m_ButtonLeft does not have a .Checked attribute. I basically want to see if the button is checked or not checked and then do something based on that state.
Thank you for all your help.
Working with Checkbox style buttons (C#)
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Hello bebenin_s,
i think you mean "Windows.Forms.Checkbox" with "Apperiance.Button" style?
If so, you can use the "Ranorex.CheckBox" class instead.
m_MessageBox = Application.FindFormTitle(formName);
m_CheckBox = m_MessageBox.FindCheckBox("btnLeft");
bool isChecked = checkBox.Checked;
Regards,
Chris
Ranorex Support Team
i think you mean "Windows.Forms.Checkbox" with "Apperiance.Button" style?
If so, you can use the "Ranorex.CheckBox" class instead.
m_MessageBox = Application.FindFormTitle(formName);
m_CheckBox = m_MessageBox.FindCheckBox("btnLeft");
bool isChecked = checkBox.Checked;
Regards,
Chris
Ranorex Support Team
Thanks!
Your suggestion did not work, but I think it's probably because this button has custom properties. After it didn't work, I opened the developers project and found that there is a custom button class that contains a Checked() method.
So I guess Ranorex doesn't pick up Misc properties of the button. Am I correct? When I use RanorexSpyPro to probe this button, there is a Misc section that contains:
Style = Checkbox
Checked = True
Both of these attributes are in this custom button class.
Is there any other way I can check the state of the button besides using the Tool Tips (since they are different)?
Thanks again![/img]
Your suggestion did not work, but I think it's probably because this button has custom properties. After it didn't work, I opened the developers project and found that there is a custom button class that contains a Checked() method.
So I guess Ranorex doesn't pick up Misc properties of the button. Am I correct? When I use RanorexSpyPro to probe this button, there is a Misc section that contains:
Style = Checkbox
Checked = True
Both of these attributes are in this custom button class.
Is there any other way I can check the state of the button besides using the Tool Tips (since they are different)?
Thanks again![/img]
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Is your custom button a .net control(windows forms)?
If so, you can get the "Checked" property with the GetPropertyValue function.
// get control z.b. with findControlId()
Control button1 = form.FindControlId(...); (check with RanorexSpyPro)
bool isChecked = button1.GetPropertyValue<bool>("Checked");
If so, you can get the "Checked" property with the GetPropertyValue function.
// get control z.b. with findControlId()
Control button1 = form.FindControlId(...); (check with RanorexSpyPro)
bool isChecked = button1.GetPropertyValue<bool>("Checked");