开发者

Where does tab goes?

开发者 https://www.devze.com 2023-02-20 14:52 出处:网络
I am working on winform proj开发者_开发问答ect. At runtime when I am moving through different controls through tab key ; after one button my tab disappears for 2 clicks. I tried all things to fix this

I am working on winform proj开发者_开发问答ect. At runtime when I am moving through different controls through tab key ; after one button my tab disappears for 2 clicks. I tried all things to fix this. I set tabstop=false for all contols in winform but still I am getting same problem.

Then I decided to add following code:

Control nextControl = this.GetNextControl(this.guipnlReportPatientMeasurementDetails.Controls[10], true);

where GetNextControl property gets the name of the control where my control will go after pressing tab key and Controls[10] is the button. So where should I place above piece of code so that I would get the name of next control. Should it be in button_click event or somewhere else ?

Guys please suggest.


You should set TabIndex property for each control according to the Tab order you want to impose (you can set it through designer).

Set TabStop = false only for those controls you want to exclude from Tab selection.

There's also a useful button that shows TabIndexes on the form:

Where does tab goes?


You are digging yourself a hole. Find out what the real problem is, there's some kind of control that is either off the window or doesn't properly indicate the focus. If you have no clue what control that might be then add a timer and a label. Set the timer's Enabled property to True, Interval to 200. Write the Tick event like this:

    private void timer1_Tick(object sender, EventArgs e) {
        if (this.ActiveControl == null) label1.Text = "No control?";
        else label1.Text = this.ActiveControl.Name;
    }

That tells you where the tab goes.


I would first try to fix the tab order on the window before resolving to using this code. Did you do that?

0

精彩评论

暂无评论...
验证码 换一张
取 消