Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > Set focus on textbox

Thread Tools Display Modes
Old 05-08-2004, 04:50 PM
AdamVB AdamVB is offline
Join Date: Apr 2004
Posts: 20
Arrow Set focus on textbox

How ca i do this:
I have a textbox1 and button1 on form1

The the button1 add a text string to the text typed on the textbox1. when i do that the blinking cursor disapear from the textbox1. how do i keep the cursor showing on the last caracter on the textbox1.

Reply With Quote
Old 05-08-2004, 05:35 PM
bear24rw's Avatar
bear24rw bear24rw is offline
Join Date: May 2004
Location: NJ
Posts: 477
Lightbulb idk....

the only thing that i can think of is

Dim s As String = "Hello"
Dim t As String = TextBox1.Text
Dim n As String
n = t & s
TextBox1.Text = n

but it highlights the whole thing so the user has to press the right arrow..... and why would you need to do that anyyway???
Use[vb][/vb] tags when posting code.
Reply With Quote
Old 05-08-2004, 06:11 PM
Iceplug's Avatar
Iceplug Iceplug is offline

Retired Moderator
* Guru *
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583

Hmm... I can't test right now, but try setting the CanFocus property of the button to False.

Alternatively, you can set the button as the AcceptButton and then you can use the Enter key on the keyboard to press the button.

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
Old 05-12-2004, 05:46 AM
fcallery's Avatar
fcallery fcallery is offline
Join Date: Oct 2003
Location: Rome - Italy
Posts: 57
Smile Add a lenght-zero string at the end!

Try this way:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = "Hello World!"
End Sub

Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Disabling Textbox Focus afrinspray General 8 08-07-2003 02:50 PM
Problem With TextBox focus mjohnson3091 General 2 06-30-2003 02:23 PM
Changing Textbox Color with Focus AnarchyX Interface and Graphics 5 03-14-2003 10:18 AM
textbox loosing focus mcm General 2 02-20-2003 02:20 PM
Textbox Lose Focus blabore General 1 02-15-2002 04:08 PM


Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..