I have created what I call a “LabeledTextBoxWithLookupControl” which inherits from UserControl. I’ve put several of these controls on a form.
Now I’m beginning to think that this was a bad idea.
When I call TopLevelControl.SelectNextControl(this, true, true, true, true) from a KeyPress event assigned to the TextBox in the UserControl, it’s actually selecting the next UserControl, where I actually want it to select the text box inside the next user control. The UserControl’s CanSelect property returns true, but I don’t see any easy way to change a UserControl’s Control Style.
Also, when I use the Tab Order mode, I’d prefer it not consider the user control itself, but the the just the TextBox in inside the UserControl as candidate for tab order. Should I override the TabIndex and TabStop properties of the UserControl and make them point to the TabIndex and TabStop of the TextBox?
Also, should I expose just the properties of the controls themselves, or should I expose each control as a property to set these properties I want to be able to set, such as the Text property of the label control, the click event of the LookupControl and the Text property of the TextBox.
If you don’t want the
UserControlto be a tab stop but rather it’s contents, you have to make sure that it doesn’t have theControlStyles.Selectablestyle.In the constructor of your
UserControladd: