473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 8687
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(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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.EventArgs) Handles MyBase.Load
Me.TextBox1.Focus()
End Sub

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

"Tosch" <to**********@swissonline.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 #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(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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.EventArgs) Handles MyBase.Load
Me.TextBox1.Focus()
End Sub

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

"Tosch" <to**********@swissonline.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
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...
2
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...
13
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...
6
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
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...
2
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
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...
5
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...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...

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.