473,735 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting focus inside a Panel

I have several applications that use panels as screens, but I can *not* seem
to set the focus for a Textbox.

Panel1.BringToF ront()
Panel1_Textbox. Focus()
' do something with a control on Panel1
Panel2.BringToF ront()
Panel2_Textbox. Focus()
' do something with a control on Panel2

When the applications are running, I can almost see the Textbox controls
receiving focus for an instant, then Nothing has focus!

How do I set the Focus on the Textbox controls ... and have it STAY there?
Mar 21 '08 #1
3 5192
On Mar 21, 10:18 pm, "jp2express " <useF...@joeswe lding.bizwrote:
I have several applications that use panels as screens, but I can *not* seem
to set the focus for a Textbox.

Panel1.BringToF ront()
Panel1_Textbox. Focus()
' do something with a control on Panel1
Panel2.BringToF ront()
Panel2_Textbox. Focus()
' do something with a control on Panel2

When the applications are running, I can almost see the Textbox controls
receiving focus for an instant, then Nothing has focus!

How do I set the Focus on the Textbox controls ... and have it STAY there?
Normally,
textbox.focus gives focus. But if you lose focus for some reason and
still you want your textbox has the focus then you should:

Private Sub TextBox1_lostfo cus(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles_ TextBox1.LostFo cus

TextBox1.Focus( )

End Sub

Therefore, when you textbox loses focus, it re-gains the focus.

Hope this helps.
Mar 21 '08 #2
Interesting trick! I will certainly give it a try. Thanks!

"kimiraikko nen" wrote:
On Mar 21, 10:18 pm, "jp2express " <useF...@joeswe lding.bizwrote:
I have several applications that use panels as screens, but I can *not* seem
to set the focus for a Textbox.

Panel1.BringToF ront()
Panel1_Textbox. Focus()
' do something with a control on Panel1
Panel2.BringToF ront()
Panel2_Textbox. Focus()
' do something with a control on Panel2

When the applications are running, I can almost see the Textbox controls
receiving focus for an instant, then Nothing has focus!

How do I set the Focus on the Textbox controls ... and have it STAY there?

Normally,
textbox.focus gives focus. But if you lose focus for some reason and
still you want your textbox has the focus then you should:

Private Sub TextBox1_lostfo cus(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles_ TextBox1.LostFo cus

TextBox1.Focus( )

End Sub

Therefore, when you textbox loses focus, it re-gains the focus.

Hope this helps.
Mar 21 '08 #3
Looks to me like such a "trick" would cause you to be in a loop with it
impossible to get "out of" the textbox!
--
Terry
"kimiraikko nen" wrote:
On Mar 21, 10:18 pm, "jp2express " <useF...@joeswe lding.bizwrote:
I have several applications that use panels as screens, but I can *not* seem
to set the focus for a Textbox.

Panel1.BringToF ront()
Panel1_Textbox. Focus()
' do something with a control on Panel1
Panel2.BringToF ront()
Panel2_Textbox. Focus()
' do something with a control on Panel2

When the applications are running, I can almost see the Textbox controls
receiving focus for an instant, then Nothing has focus!

How do I set the Focus on the Textbox controls ... and have it STAY there?

Normally,
textbox.focus gives focus. But if you lose focus for some reason and
still you want your textbox has the focus then you should:

Private Sub TextBox1_lostfo cus(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles_ TextBox1.LostFo cus

TextBox1.Focus( )

End Sub

Therefore, when you textbox loses focus, it re-gains the focus.

Hope this helps.
Mar 23 '08 #4

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

Similar topics

21
9911
by: | last post by:
Hi, I am setting the NumericUpDown .Value property and the ValueChanged event is NOT being fired. Does this ONLY get fired when I change it on the UI and not programatically? Thanks
2
1583
by: IMRAN SAROIA | last post by:
Hi! Please advise how to set focus to any control on Web and Windows Forms. Regards Imran
1
1898
by: Jason | last post by:
I have created a c-sharp app that has keyup, keydown events tied to the form. The form also has some other controls, buttons, labels and 1 custom control that I made which inherits from user control. My problem is ... When I first start the app all my keyboard events work fine and by doing debugging I can see that my form has the focus. After I click on a button or my custom control the focus is shifted to those controls and the keyup,...
12
4904
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 cmdButton1_Clicked() { document.all('txtInput1').focus(); return false; }
3
2306
by: Mike Eaton | last post by:
Hi there, I've got what I hope is a simple problem to solve... Here's the back story: I have a windows form. On the form is a panel containing three textboxes. Also on the form is a text box and an ok button. Here's the problem: On condition A, I want input focus to go to a textbox on the panel when the form loads. On condition B, I want the input focus to go to the textbox that's on the form when the form loads. Seems pretty...
3
1681
by: hula | last post by:
Hello againe a "basic" question on UserControls. I have some UserControls inside a panel. Inside the controls i have checkboxes, comboboxes and textboxes. On change of any data inside the control i like to save the actual done change. I can do this on the checkboxes or combos, by using the events provided by the controls.
2
2219
by: Rob | last post by:
I have a dynamically created User Control inside of a dynamically created Flow Layout Panel inside of a Tab control added at design time.... The form where the Tab Control resides is a Singleton Type Form. How can I set the focus to a text box in the the Singleton form when a user has clicked on one of the User Controls ? Can I create a property that allows you to set the focus ?
3
1460
by: nityaprashant | last post by:
how to set focus on textbox inside panel(asp panel) inside ajax update panel plz help me..it's urgent...
1
1851
by: Farsheed Ashouri | last post by:
Hi everyone. I create a little browser with wxpython and IEHtmlWindow. But I have a little problem here. When I press enter in the html page, The focus goes to another panel. Why this happens? I want to load a html page and it have textares and user should able to press enter inside html page. This is the code for creating it: #===================Code Begin ==========================
0
8965
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8786
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9466
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9255
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6050
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4567
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4823
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2191
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.