K
Karsten Schlender
Hello,
i have a litte problem with an UserControl as a child of a TabControl.
My UserControl consists of several TextBoxes. This UserControl is placed
on a TabPage, but not the first one. When my program starts i use the
Form Load Event to select the TabPage containing my UserControl by
calling tabControl1.SelectTab(1). The strange thing now is, that my
first TextBox in the UserControl gets the focus and shows the cursor
although the selected TabPage itself should have it. When i place the
TextBoxes directly in a TabPage and select the page as described above,
it works fine, my page gets the focus and i can navigate with the cursor
keys through the TabPages.
It's not a problem specific to the UserControl. It must lie deeper,
maybe in ContainerControl as baseclass, because ToolStripContainer shows
the same strange behaviour.
I know that ContainerControl has a different focus behaviour and selects
the first child control when it's focused. That's maybe the reason of my
focused TextBox. But why gets the UserControl focus in the first place?
When you manually select the different TabPages with a mouse click, this
behaviour of "focus stealing" of the UserControls does not take place.
Do i miss something in my thoughts?
Kind regards,
Karsten
i have a litte problem with an UserControl as a child of a TabControl.
My UserControl consists of several TextBoxes. This UserControl is placed
on a TabPage, but not the first one. When my program starts i use the
Form Load Event to select the TabPage containing my UserControl by
calling tabControl1.SelectTab(1). The strange thing now is, that my
first TextBox in the UserControl gets the focus and shows the cursor
although the selected TabPage itself should have it. When i place the
TextBoxes directly in a TabPage and select the page as described above,
it works fine, my page gets the focus and i can navigate with the cursor
keys through the TabPages.
It's not a problem specific to the UserControl. It must lie deeper,
maybe in ContainerControl as baseclass, because ToolStripContainer shows
the same strange behaviour.
I know that ContainerControl has a different focus behaviour and selects
the first child control when it's focused. That's maybe the reason of my
focused TextBox. But why gets the UserControl focus in the first place?
When you manually select the different TabPages with a mouse click, this
behaviour of "focus stealing" of the UserControls does not take place.
Do i miss something in my thoughts?
Kind regards,
Karsten