Link between Toggle and e.g. the RadioButton behind it? - radio-button

Imaging e.g. 2 RadioButtons which share one ToggleGroup. Using
ToggleGroup.getToggles()
one can access all Toggles of the ToggleGroup. But is there any reference from a Toggle to the RadioButton that is linked to?

If I understood the question correctly you're looking for:
RadioButton button = (RadioButton) toggleGroup.getSelectedToggle();
Unfortunatly, the ToggleGroup isn't "generified" yet, so you need the cast.
But is there any reference from a Toggle to the RadioButton that is
linked to?
Or in other words: RadioButton is a (implements) Toggle, there isn't any reference.

Related

Button click inside repeater UpdatePanel problem

I have button inside of repeater in a contentpage.
How can I use update panel with that?
I want to make that,
Button click inside a repeater triggers itemcommand function and after that not posstback refresh.
Best regards
Do you want this result?
Microsoft officially gave some good cases, you can refer to the following:
Specify and code handlers for the ItemCommand event of the Repeater control

Checkbox with image and autosize

In Word 2012 I have seen the following checkbox:
I am wondering if this checkbox is a .NET control with an image assigned to it (with property "imagealign" being middle right) or if this is a custom solution by MS for their Office GUIs.
I can reproduce the appearance, but I am unable to easily check if the user clicks the checkbox (and wants to change its state) or the info button and wants to show the tooltip.
Also, I have to add some spaces at the end of the checkbox text, else the image is under the text if the checkbox autosize property is set to True.
I would tend to think that the checkbox is a custom solution by MS or perhaps the image is a separate control.
Does anybody know more about this?
I think you are looking for
Checkbox.AutoSize = False
CheckBox.Image = "Your Image"
CheckBox.ImageAlign = MiddleRight
But this way you won't be able to distinguish if the user clicks the checkbox or the info button to show the tooltip.
As far as I know, there is no control available at .NET which allows this behavior, so I suppose they are using separate controls.
I think you'll need to use a PictureBox near the CheckBox and then use CheckBox_CheckedChanged and PictureBox_Click events to do whatever you want on each case.

What is a good strategy to integrate radio buttons?

Basically I have three radio buttons and only want one button selected at at time, of course when created they are independent of each other. Currently, I use change listeners to interweave the buttons and it works in my context just fine. But, I realize this really isn't the best way because the code becomes cumbersome when more buttons are needed or if a particular section of code goes under many changes and several other reasons. So, how can I better integrate radio buttons (or anything where behavior depends on the integration of multiple controls <-- if someone wants to rephrase this please do so)?
Use a ToggleGroup:
A class which contains a reference to all Toggles whose selected
variables should be managed such that only a single Toggle within the
ToggleGroup may be selected at any one time.
There is an example in the RadioButton javadoc:
ToggleGroup group = new ToggleGroup();
RadioButton button1 = new RadioButton("select first");
button1.setToggleGroup(group);
button1.setSelected(true);
RadioButton button2 = new RadioButton("select second");
button2.setToggleGroup(group);

Default Button on Form (VB 2008)

I want to find a way to make a specific button, the form's default button,
I.e. the button that is highlighted when the form opens for the first time.
I tried the AcceptButton property but when I run the program, that does not work.
Any idea?
Thank you in advance,
Tassos
You need to change the AcceptButton property of the containing form.
form1.AcceptButton = button1
Here form1 is the Form whose default button you need to set, and button1 is the name of the Button on that form.
The form's AcceptButton and CancelButton properties define the default behaviour for the Enter and Escape keys, rather than the highlighting.
To highlight the button use the Focus method, but when doing this in the form_load event you will need to call the Select method instead.
btnDefault.Select()
As mentioned in the comments, setting the control to the lowest taborder will achieve the same thing
The answer from 'chk' on 5/2/13 is the correct answer, but is shown as a string which of course is not the way to do it.
Also, in the form's property sheet you can find, under Misc, the property 'AcceptButton'. This will give you a list of buttons on the form - just select the one you want.
The button selected as the AcceptButton will behave as the 'default' button. It will be 'highlighted' with a darker border and will be clicked when you push the Enter key on your keyboard.
Setting up an AcceptButton is different than setting the button's focus. The AcceptButton's click event will be triggered by the Enter key no matter which control has the focus on the form.
You can also do this programmatically.
I have a maintenance form where initially I want the "search" button as the form accept button.
when I'm displaying the field maintenance area, I want the "ok" button to be the accept button.
You simply change this in the appropriate areas in your code to Me.AcceptButton = MyButtonName.

Accessing Datarepeater Button

I have added a button in datarepeater. If clicked once, it executes code and Button.text should change to Yes. Clicked again, it executes the opposite code and button.text should change to No. Codes are being executed (I am using flag variable) but Button.text is not changing.
How to change this text. I am simply trying Button.text="Yes" but probably I need to give some reference of the row no. too. How to do it?
Please advise.
Thanks
Furqan
Please check this question:
Handle Button Click in WinForm DataRepeater C# Power Pack
Also: the CurrentItem property has a property named Controls that allows you to access its child controls like this: CurrentItem.Controls["OKButton"]