472,989 Members | 2,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,989 software developers and data experts.

Setting Control Focus

I am working on an application that has a UI that supports multiuple
functions by means of a group of "plug ins". Each plugin is a class
library. Each plugin contains a User Control that defines the controls
for that plugin's main form. The UI has a PictureBox control that is
nothing but a contain to add the UserControl from the selected plugin,
so that when the user selects a plugin, the main form changes
appearance to the UserControl in the selected plugin. When the UI
first launches, it loads the plugin from the last time the app was
shut down.

My problem is this. Whether the application first launches or the user
selects a different plugin, I cannot get the first control in the
UserControl to have focus. Each plugin's UserControl has a special
Initialize method that the plugin inovkes when it is loaded to set
some initial values. In one plugin, it populates a ComboBox. I have a
statement in the UserControl's Initialize method to set the focus to
the first control in the UserControl, but it doesn't seem to work. The
first control in each plugin's UserControl never gets focus
automatically, I have to click in the control for it to get focus.

Any idea how I can achieve this? I have tried to invoke the first
control's Select method instead of the Focus method and that doesn't
help.
Aug 4 '08 #1
3 2394
On Aug 4, 3:55 pm, za...@construction-imaging.com wrote:
I am working on an application that has a UI that supports multiuple
functions by means of a group of "plug ins". Each plugin is a class
library. Each plugin contains a User Control that defines the controls
for that plugin's main form. The UI has a PictureBox control that is
nothing but a contain to add the UserControl from the selected plugin,
so that when the user selects a plugin, the main form changes
appearance to the UserControl in the selected plugin. When the UI
first launches, it loads the plugin from the last time the app was
shut down.

My problem is this. Whether the application first launches or the user
selects a different plugin, I cannot get the first control in the
UserControl to have focus. Each plugin's UserControl has a special
Initialize method that the plugin inovkes when it is loaded to set
some initial values. In one plugin, it populates a ComboBox. I have a
statement in the UserControl's Initialize method to set the focus to
the first control in the UserControl, but it doesn't seem to work. The
first control in each plugin's UserControl never gets focus
automatically, I have to click in the control for it to get focus.

Any idea how I can achieve this? I have tried to invoke the first
control's Select method instead of the Focus method and that doesn't
help.
what if the plugin interface you define which control should have teh
focus?
in this case the container is responsible to give focus when needs to
(like in onLoad)
Aug 4 '08 #2
On Mon, 04 Aug 2008 12:55:36 -0700, <za***@construction-imaging.comwrote:
[...]
My problem is this. Whether the application first launches or the user
selects a different plugin, I cannot get the first control in the
UserControl to have focus. [...]

Any idea how I can achieve this? I have tried to invoke the first
control's Select method instead of the Focus method and that doesn't
help.
A concise-but-complete code sample would go a long way.

That said, the first thing I'd suggest is to stop abusing the PictureBox
class. It's not a container control. Use something more appropriate,
like Panel or even UserControl (both of which are intended for use as
containers).

It's possible (I didn't look into it closely myself) that the PictureBox
class just doesn't accept focus. That may have implications for
attempting to set focus to it or its children.

Pete
Aug 4 '08 #3
On Aug 4, 4:23*pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
On Mon, 04 Aug 2008 12:55:36 -0700, <za...@construction-imaging.comwrote:
[...]
My problem is this. Whether the application first launches or the user
selects a different plugin, I cannot get the first control in the
UserControl to have focus. [...]
Any idea how I can achieve this? I have tried to invoke the first
control's Select method instead of the Focus method and that doesn't
help.

A concise-but-complete code sample would go a long way.

That said, the first thing I'd suggest is to stop abusing the PictureBox *
class. *It's not a container control. *Use something more appropriate, *
like Panel or even UserControl (both of which are intended for use as *
containers).

It's possible (I didn't look into it closely myself) that the PictureBox *
class just doesn't accept focus. *That may have implications for *
attempting to set focus to it or its children.
Thanks for the suggestions.

After plugging away on thisd I figured out what was missing. After I
add the plugin's UserControl to the PictureBox's controls, I then
invoke the Select method for PictureBox.Controls[0].

And as far as using a PictureBox control as a container, I did not do
the design, but I will pass along your comments to the person who did.
Aug 4 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: IMRAN SAROIA | last post by:
Hi! Please advise how to set focus to any control on Web and Windows Forms. Regards Imran
2
by: MLH | last post by:
A form named frmVehicleEntryForm has a number of textbox controls who's OnGotFocus property setting is an expression... =Change2Green() Change2Green() looks something like this... Dim MyControl...
12
by: CLEAR-RCIC | last post by:
Hi, I'm having problems setting focus to a textbox on a web user contol on an asp.net web page. The following script works on normal asp.net pages: <script language="javascript"> function...
2
by: Sridhar | last post by:
Hi, I have a question. I have created a user control which contains a textbox and a button. we will enter some search word in the textbox and hit the button. Then we will get a pop-up with the...
1
by: clickon | last post by:
For testing purposes i have got a 2 step WizardControl. Eqach step contains a text box, TextBox1 and TextBox2 respectively. If i put the following code in the respective activate event handlers...
1
by: clickon | last post by:
For testing purposes i have got a 2 step WizardControl. Eqach step contains a text box, TextBox1 and TextBox2 respectively. If i put the following code in the respective activate event handlers for...
7
by: Zytan | last post by:
I want to set a control in a form to have the default focus. This is not the accept button -- that's set to a button when is 'clicked' when you press ENTER. I want a textbox to have the focus...
5
by: Finn Stampe Mikkelsen | last post by:
Hi How can i set a focus to a textbox in my codebehind page?? I have this WebForm, that takes information from a user and 2 buttons on the form. One that takes action on the entered...
3
by: kelvin.koogan | last post by:
I have a number of controls on a tab page. I want to validate them all when the user tries to leave the tab. I then want to highlight the first control which fails validation. How can I do this? I...
2
by: angi35 | last post by:
I hope this is an easy question for someone out there. In Access 2000I have a MainForm with a tab control (MAIN TABS) with 7 tabs. Within each tab is a SubForm. Within each SubForm is a tab...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.