473,724 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cant set focus to textbox

I have a usercontrol with a label, a textbox, a treeview, a grid and a
couple of checkboxes.
The usercontrol is hosted on a form together with a cancel and a
accept button. This form is used to search records in a database.

On several forms in my application I show (modal) this form to search
records. Everytime I show the form I want the focus to be on the
textbox on the usercontrol.
This works the first time I display the form. But every other time I
just can't get the textbox to receive the focus.
I have tried everything.
I have setup a timer that goes off and tries to set the focus to the
textbox. The textbox.Focus returns false. I have checked the
..Activecontrol property and it tells me the textbox has the focus.
When I press TAB and then ShiftTab the focus is on the textbox. So
before pressing Tab it must have been on the textbox.
But no cursor is displayed and I can't enter any text.

Does anyone have an idea to force the focus to the textbox?

Tosch
Nov 21 '05 #1
5 8728
I didn't get it clearly... if the textBox is on the modal from then it is
very easy to set the focus to its textBox when the modal form is shown.
I used this:

' In the calling form:

Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button2.Click
Dim f As New SplashForm
f.ShowDialog()
End Sub

' In the Splash or search from which you set as a dialog from:

Private Sub SplashForm_Load (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Me.TextBox1.Foc us()
End Sub

' Be sure to close the dialog form everytime the work with it finishes.
Correct me if i was wrong

"Tosch" <to**********@s wissonline.ch> wrote in message
news:c8******** *************** *********@4ax.c om...
I have a usercontrol with a label, a textbox, a treeview, a grid and a
couple of checkboxes.
The usercontrol is hosted on a form together with a cancel and a
accept button. This form is used to search records in a database.

On several forms in my application I show (modal) this form to search
records. Everytime I show the form I want the focus to be on the
textbox on the usercontrol.
This works the first time I display the form. But every other time I
just can't get the textbox to receive the focus.
I have tried everything.
I have setup a timer that goes off and tries to set the focus to the
textbox. The textbox.Focus returns false. I have checked the
.Activecontrol property and it tells me the textbox has the focus.
When I press TAB and then ShiftTab the focus is on the textbox. So
before pressing Tab it must have been on the textbox.
But no cursor is displayed and I can't enter any text.

Does anyone have an idea to force the focus to the textbox?

Tosch

Nov 21 '05 #2
Joop,
no the textbox is on the usercontrol. There is no textbox on the form,
just the usercontrol and two buttons.

Tosch

On Thu, 21 Apr 2005 11:14:18 +0430, "Joop" <ip*@nt.co> wrote:
I didn't get it clearly... if the textBox is on the modal from then it is
very easy to set the focus to its textBox when the modal form is shown.
I used this:

' In the calling form:

Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventAr gs) Handles Button2.Click
Dim f As New SplashForm
f.ShowDialog()
End Sub

' In the Splash or search from which you set as a dialog from:

Private Sub SplashForm_Load (ByVal sender As System.Object, ByVal e As
System.EventAr gs) Handles MyBase.Load
Me.TextBox1.Foc us()
End Sub

' Be sure to close the dialog form everytime the work with it finishes.
Correct me if i was wrong

"Tosch" <to**********@s wissonline.ch> wrote in message
news:c8******* *************** **********@4ax. com...
I have a usercontrol with a label, a textbox, a treeview, a grid and a
couple of checkboxes.
The usercontrol is hosted on a form together with a cancel and a
accept button. This form is used to search records in a database.

On several forms in my application I show (modal) this form to search
records. Everytime I show the form I want the focus to be on the
textbox on the usercontrol.
This works the first time I display the form. But every other time I
just can't get the textbox to receive the focus.
I have tried everything.
I have setup a timer that goes off and tries to set the focus to the
textbox. The textbox.Focus returns false. I have checked the
.Activecontrol property and it tells me the textbox has the focus.
When I press TAB and then ShiftTab the focus is on the textbox. So
before pressing Tab it must have been on the textbox.
But no cursor is displayed and I can't enter any text.

Does anyone have an idea to force the focus to the textbox?

Tosch


Nov 21 '05 #3
Tosch,

Did you everwhere set your tabindexes right.
(usercontrol and form)

I hope this helps,

Cor
Nov 21 '05 #4
Yes, checked this several times.
On Thu, 21 Apr 2005 09:44:54 +0200, "Cor Ligthert"
<no************ @planet.nl> wrote:
Tosch,

Did you everwhere set your tabindexes right.
(usercontrol and form)

I hope this helps,

Cor


Nov 21 '05 #5
Tosch,

And how did you set them, for me it works that way.

Cor
Nov 21 '05 #6

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

Similar topics

17
3856
by: Neil Ginsberg | last post by:
OK, this is a stupid thing, but I can't seem to get this to work. I have a form with a subform (in continuous form view). A combo box on the main form has code in the AfterUpdate event which adds a record to the subform (based on the value of the combo box) and requeries the subform control. I want the focus to return to the combo box on the main form when it's done, but I can't get it to do so if the user enters a value and presses Enter...
2
4962
by: zdavid | last post by:
Hi, I have a dialog box with a multiline textbox and three buttons. The obvious thing I'm suffering with is how to give focus to the textbox, so that when the dialogbox pops up, the user could immediately start typing without having to click in the textbox. I tried textBox.Focus(), textBox.SelectAll() with no success... The tabindex of the textbox is set to 0, which should mean that the textbox would have the focus when the dialogbox is...
13
6938
by: Stefan | last post by:
hello, Just a sort of newbie question. How can i change the backcolor of the controls which have the focus (textbox/combobox/datetimepicker) and set it back to white when they lost focus. thanx in advance Stefan
6
1513
by: RedS | last post by:
Hi I have two texbox A and B. What I want to ask is how to set if I press enter in textbox A and it set focus to textbox B. Thanks
1
2515
by: Praveena.Alapati | last post by:
Hi, There is a tab control on a page with multiple tabs and handful of controls in each tab. The way it's rendered in html (like grid etc..) is in table format in tablerows and cells. On clientside, on form validation in javascript, I would like to set focus on to one of the tabs and set the focus to the control on that tab.
2
1702
by: venkatarp | last post by:
Hi , I am facing one different problem. I have dropdown and textbox. After i selected drop down textbox should focus. But its disabled and not focussing......
3
5777
by: S Moran | last post by:
private void button1_Click(object sender, EventArgs e) { textBox1.SelectionStart = 0; textBox1.SelectionLength = textBox1.Text.Length; } yet when the button is clicked and there is text in the textbox.... NOTHING. what am i missing here?
5
13501
montzter
by: montzter | last post by:
Hi evryone, I'm having trouble in formatting the inputed data in the text box so that everytime user lost focus it will adjust its value to contain the format (#,####.##). ie user will input 1111.1 it will immediately be converted to 1,111.10 as its value. I've tried using this code in every lost focus: textbox.text = round(val(textbox.text)), 2) but the problem with this is I am not getting the comma and if the user enters an exact...
1
2464
by: rakeshnair | last post by:
i wrote a code in jsp to create dynamic table..the problem is i need data base connection when cursor moves from one cell to other... eg...when i enter product id in the first cell, the product name and its rate should come in the next two cells...it should take from the data base... it's my code........ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" > <%@ page import="java.sql.*"...
0
8741
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
9389
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
9090
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8063
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4504
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
4771
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3210
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2613
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2149
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.