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


Reply
 
Thread Tools Display Modes
  #1  
Old 05-08-2004, 05:50 PM
AdamVB AdamVB is offline
Newcomer
 
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
  #2  
Old 05-08-2004, 06:35 PM
bear24rw's Avatar
bear24rw bear24rw is offline
Contributor
 
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
TextBox1.Focus()

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
  #3  
Old 05-08-2004, 07:11 PM
Iceplug's Avatar
Iceplug Iceplug is offline
MetaCenturion

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

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
  #4  
Old 05-12-2004, 06:46 AM
fcallery's Avatar
fcallery fcallery is offline
Regular
 
Join Date: Oct 2003
Location: Rome - Italy
Posts: 57
Smile Add a lenght-zero string at the end!

Try this way:

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

Bye!
Fabrizio
Reply With Quote
Reply


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 03:50 PM
Problem With TextBox focus mjohnson3091 General 2 06-30-2003 03: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

Advertisement:





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.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
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..
subscribe
 
 
-->