Hi there,
I'm trying to do an easy thing... but no luck so far...
I have a form with a textbox, and I want the following behaviour on mouse
click event:
-if no text is selected, select all
-if some (or all) text is selected, unselect all
This looks good... but doesn't work! :-(
Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.Click
If TextBox1.SelectionLength > 0 Then
TextBox1.Select(0, 0)
Else
TextBox1.SelectAll()
End If
End Sub
I set a breakpoint on "TextBox1.Select(0,0)", never stops there; and I dont
see why?
How can I get the behaviour I want?
Please help me... to master this nasty TextBox!
Regards,
Mario 4 1493
Hi Mario,
Can it be that by clicking on the textbox you deselect everything?
:-)
You can make a seperate button to try or maybe use the mouse.down, I never
tried that (just a guess).
Cor
No, sorry, using a button is not acceptable, not it is sendkeys, or other
bogus workarrounds.
Thanks any way.
Regards,
Mario
"Cor" <no*@non.com> wrote in message
news:uW**************@tk2msftngp13.phx.gbl... Hi Mario,
Can it be that by clicking on the textbox you deselect everything? :-) You can make a seperate button to try or maybe use the mouse.down, I never tried that (just a guess).
Cor
Cor is right. Clicking the textbox deselects the text. Therefore, it will
always be zero. Try this it out. It works.
Dim hold As Integer
Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox1.Click
If hold > 0 Then
TextBox1.Select(0, 0)
Else
TextBox1.SelectAll()
End If
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
TextBox1.Select(0, 5)
hold = TextBox1.SelectionLength
End Sub
"Cor" <no*@non.com> wrote in message
news:uW**************@tk2msftngp13.phx.gbl... Hi Mario,
Can it be that by clicking on the textbox you deselect everything? :-) You can make a seperate button to try or maybe use the mouse.down, I never tried that (just a guess).
Cor
Hi Brian,
Thank's. Not exactly like you said, but you gave me a good idea, to cache
the selection length.
Static hold As Integer
If hold > 0 Then
TextBox1.Select(0, 0)
hold = 0
Else
TextBox1.SelectAll()
hold = TextBox1.SelectionLength
End If
Regards,
Mario
"Brian" <no****@prairie.lakes.com> wrote in message
news:vp************@corp.supernews.com... Cor is right. Clicking the textbox deselects the text. Therefore, it will always be zero. Try this it out. It works.
Dim hold As Integer
Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Click If hold > 0 Then TextBox1.Select(0, 0) Else TextBox1.SelectAll() End If End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load TextBox1.Select(0, 5) hold = TextBox1.SelectionLength End Sub
"Cor" <no*@non.com> wrote in message news:uW**************@tk2msftngp13.phx.gbl... Hi Mario,
Can it be that by clicking on the textbox you deselect everything? :-) You can make a seperate button to try or maybe use the mouse.down, I
never tried that (just a guess).
Cor
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Michael |
last post by:
Hi!
I have installed PHP 4.3.7 on Apache 2.0 on RH9.
Everything seems to go well( When I run <?php phpinfo() ;?> it works)
but I can't manage up with values.Even in the simplest programm, I
can't...
|
by: Michael Strorm |
last post by:
Hi!
I posted a message a while back asking for project suggestions, and decided
to go with the idea of creating an adventure game (although it was never
intended to be a 'proper' game, rather an...
|
by: Jonas Smithson |
last post by:
<div style="position: relative;> <!-- I'm the parent -->
blah blah blah
<div style="position: absolute; bottom: 0;> <!-- I'm the child -->
blah blah blah
</div>
</div>
The bottom of the...
|
by: Andrew Baker |
last post by:
Have a look at the code below. It's a really simple example where I
have added two controls to a form, a textbox and a combo box. Both add
owner drawn context menus to the controls, but the...
|
by: Jerry |
last post by:
I managed to narrow this down to a very simple expression. try this:
private void Bug()
{
bool b = false;
Test(3, (b || b) && b && !b);
}
private void Works()
{
|
by: tranky |
last post by:
Hi, i'm italian...so...excuse me for my english.
I've a little problem....in what manner i can check a textbox for know if it
contain only character from A-Z (a-z), numbers (0-9), and underscore...
|
by: Mark Olbert |
last post by:
I just spent several frustrating hours tracking down a subtle problem involving a simple web page. I'm sharing the solution so as to
spare others a similar experience.
The web page has only three...
|
by: teo |
last post by:
Hallo,
in a TextBox I implemented the AutoComplete function
So the little AutoComplete window appears under the TextBox.
But the Font is too big and the window Size is too little.
How can I...
|
by: spamtrap |
last post by:
Hy;
I've got a nasty variation of the Guillotine-bug on a three-column
layout, sadly the variations of the Holly-hack I tried to apply don't
work:
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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,...
|
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: 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...
| |