I have a child form that I load from a parent form. The parent form is NOT a MDI parent. I would like to do the following:
I would like to disable the dotted/dashed rectangle around controls that have focus, particularly Buttons and RadioButtons.
Currently I am using the following code:
foreach (System.Windows.Forms.Control control in this.Controls)
{
// Prevent button(s) and RadioButtons getting focus
if (control is Button | control is RadioButton)
{
HelperFunctions.SetStyle(control, ControlStyles.Selectable, false);
}
}
where my SetStyle method is
public static void SetStyle(System.Windows.Forms.Control control, ControlStyles styles,
bool newValue)
{
// .. set control styles for the form
object[] args = { styles, newValue };
typeof(System.Windows.Forms.Control).InvokeMember("SetStyle",
BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod,
null, control, args);
}
Needless to say, this does not seem to work. I am not sure what I am missing here. Any suggestions and/or advice would be greatly appreciated.