Hey

I am using a devexpress tabcontrol.

I have a created a program that allows the user to select an option button and that button takes them to the correct tab.

Ive set all the tabs to visable = false untill the option button has been selected.

The problem i am having is setting the focus, so the button sgoes to the tab instead of just making it visable again.

I know normally you would use the setfocus = ture command but with
devexpress tabcontrol this function does not work.

does anyone have ideas on the code am meant to use

Thanks for your help

Dani AI

Generated

Short answer: programmatically select the tab page and then give keyboard focus to a focusable control on that page. Making a page visible alone only makes the tab show up — the tab page is a container and usually will not receive keyboard focus itself, so you need to set the tab as selected and then call Focus() on a child control (or on the tab control) after selection.

Both and were on the right track by changing the selected page from code. The missing piece is the focus target and the timing: set the page visible, select it, then set focus to a specific input control on that page (for example the first TextBox/TextEdit). If you try to call Focus immediately during the option-button event and it does not stick, defer the Focus call until after the UI finishes switching pages (SelectedPageChanged, BeginInvoke or a short timer).

Example pattern (VB.NET):

' make the page visible and select it
Dim pg As DevExpress.XtraTab.XtraTabPage = tabMain.TabPages(0)
pg.PageVisible = True
tabMain.SelectedTabPageIndex = 0

' focus the first enabled/visible child control, fallback to the tab control
Dim focused As Boolean = False
For Each c As Control In pg.Controls
    If c.Visible AndAlso c.Enabled Then
        c.Focus()
        focused = True
        Exit For
    End If
Next

If Not focused Then tabMain.Focus()

Troubleshooting tips: ensure the control you focus is Enabled and Visible; try setting focus in the SelectedPageChanged handler or via BeginInvoke if it fails during the option-button click; avoid relying on the tab page itself to get focus — target a real input control for consistent keyboard focus.

Recommended Answers

All 2 Replies

Have you tried -

'Depending on the option selected

TabControl1.Tab=0 'or 1 etc.

Not sure if this will help in Dev though...

following code allows you to set focus to the selected tab index.

tabMain.SelectedTabPage = tabMain.TabPages.Item(0)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.