views:

3003

answers:

1

I have lots of radiobutton in a panel with auto scroll set to true. One of theradiobutton is checked. I want to make sure that that the checked one should be visible i.e. the vertical scrollbar should be moved so that the checked radio button is visible. Is there any way to do it?

P.S. I have tried as bellow but it is not working

            RadioButton radiobutton = new RadioButton();
            .....
            panel.Controls.Add(radioButton);
            if (some logic)
            {
                radioButton.Checked = true;
                panel.ScrollControlIntoView(radioButton);
            }
A: 

To fix this, i add the above mentioned code (panel.ScrollControlIntoView(radioButton)) after the form is shown (i.e. in the event handler for form_Shown event). This is wrkoing now. But I still dont have the correct explanation for this.

malay
it will be great if anybody could give explanation for this behavior. Thanks
malay