Hi,
Sorry this is a long message, but I'm getting desperate (and worried). I
have a textbox (say, tb1) where the string is longer than the width of the
box. If I'm coming from the previous textbox (tb0) (by tabbing or pressing
enter or the down arrow), the text inside tb1 highlights and the cursor is at
the end of the string (so that the beginning of the string isn't visible).
If I type absolutely any key(s) other than Tab, Up, Down, or Enter, then
press either Tab, Up, Down, or Enter, the tb1.SelectionStart = 0; works so
that tb1 shows the string from the beginning, and moves on to highlight the
text in the next textbox. But if I press nothing before pressing Up, Down,
Tab, or Enter, tb1 keeps the string as it was when it was highlighted - the
beginning cut off, and then moves on to highlight the next box. It
completely ignores the tb1.SelectionStart = 0;. Here is what I write for the
KeyDown event for tb1:
private void tb1Down(object sender, System.Windows.Forms.KeyEventArgs e)
{
if ((e.KeyCode == Keys.Tab) || (e.KeyCode == Keys.Enter) || (e.KeyCode ==
Keys.Down) || (e.KeyCode == Keys.Up))
{
...save this and that...
tb1.SelectionStart = 0;
if (e.KeyCode == Keys.Up)
{tb0.SelectionStart = 0; tb0.SelectionLength = tb0.Text.Length; tb0.Focus();}
else {tb2.SelectionStart = 0; tb2.SelectionLength = tb2.Text.Length;
tb2.Focus();}
}
I've also tried to put tb1.SelectionStart = 0; in the tb1Leave event, and it
doesn't work:
private void tb1Leave(object sender, System.EventArgs e)
{
....save something else...
if (tb1.Focus() == true){MessageBox.Show("tb1Focus"); tb.SelectionStart = 0;}
}
Then I tried adding SendKeys.Send("{Home}"); just after the if (e.KeyCode ==
Tab || ...) statement in the KeyDown event, but what it did was send the Home
key to the next textbox so that the next textbox wasn't highlighted, and the
cursor was at the beginning of the text.
I have no idea what else I can try.
Please help!!!
Thanks again,
Mel 4 1303
>> I have a textbox (say, tb1) where the string is longer than the width of
the box.
Make your text box wider.
"melanieab" wrote: Hi, Sorry this is a long message, but I'm getting desperate (and worried). I have a textbox (say, tb1) where the string is longer than the width of the box. If I'm coming from the previous textbox (tb0) (by tabbing or pressing enter or the down arrow), the text inside tb1 highlights and the cursor is at the end of the string (so that the beginning of the string isn't visible). If I type absolutely any key(s) other than Tab, Up, Down, or Enter, then press either Tab, Up, Down, or Enter, the tb1.SelectionStart = 0; works so that tb1 shows the string from the beginning, and moves on to highlight the text in the next textbox. But if I press nothing before pressing Up, Down, Tab, or Enter, tb1 keeps the string as it was when it was highlighted - the beginning cut off, and then moves on to highlight the next box. It completely ignores the tb1.SelectionStart = 0;. Here is what I write for the KeyDown event for tb1:
private void tb1Down(object sender, System.Windows.Forms.KeyEventArgs e) { if ((e.KeyCode == Keys.Tab) || (e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Down) || (e.KeyCode == Keys.Up)) { ...save this and that... tb1.SelectionStart = 0; if (e.KeyCode == Keys.Up) {tb0.SelectionStart = 0; tb0.SelectionLength = tb0.Text.Length; tb0.Focus();} else {tb2.SelectionStart = 0; tb2.SelectionLength = tb2.Text.Length; tb2.Focus();} }
I've also tried to put tb1.SelectionStart = 0; in the tb1Leave event, and it doesn't work:
private void tb1Leave(object sender, System.EventArgs e) { ...save something else... if (tb1.Focus() == true){MessageBox.Show("tb1Focus"); tb.SelectionStart = 0;} }
Then I tried adding SendKeys.Send("{Home}"); just after the if (e.KeyCode == Tab || ...) statement in the KeyDown event, but what it did was send the Home key to the next textbox so that the next textbox wasn't highlighted, and the cursor was at the beginning of the text. I have no idea what else I can try. Please help!!! Thanks again, Mel
melanieab wrote: Hi, Sorry this is a long message, but I'm getting desperate (and worried). I have a textbox (say, tb1) where the string is longer than the width of the box. If I'm coming from the previous textbox (tb0) (by tabbing or pressing enter or the down arrow), the text inside tb1 highlights and the cursor is at the end of the string (so that the beginning of the string isn't visible). If I type absolutely any key(s) other than Tab, Up, Down, or Enter, then press either Tab, Up, Down, or Enter, the tb1.SelectionStart = 0; works so that tb1 shows the string from the beginning, and moves on to highlight the text in the next textbox. But if I press nothing before pressing Up, Down, Tab, or Enter, tb1 keeps the string as it was when it was highlighted - the beginning cut off, and then moves on to highlight the next box. It completely ignores the tb1.SelectionStart = 0;. Here is what I write for the KeyDown event for tb1:
private void tb1Down(object sender, System.Windows.Forms.KeyEventArgs e) { if ((e.KeyCode == Keys.Tab) || (e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Down) || (e.KeyCode == Keys.Up)) { ...save this and that... tb1.SelectionStart = 0; if (e.KeyCode == Keys.Up) {tb0.SelectionStart = 0; tb0.SelectionLength = tb0.Text.Length; tb0.Focus();} else {tb2.SelectionStart = 0; tb2.SelectionLength = tb2.Text.Length; tb2.Focus();} }
Rather than SelectionStart and Selection length, just use the Select
method:
tb1.Select(0, 0);
in the leave event. It should work.
Thanks so much!!!!
(and happy holidays)
Mel
"Matt" wrote: melanieab wrote: Hi, Sorry this is a long message, but I'm getting desperate (and worried). I have a textbox (say, tb1) where the string is longer than the width of the box. If I'm coming from the previous textbox (tb0) (by tabbing or pressing enter or the down arrow), the text inside tb1 highlights and the cursor is at the end of the string (so that the beginning of the string isn't visible). If I type absolutely any key(s) other than Tab, Up, Down, or Enter, then press either Tab, Up, Down, or Enter, the tb1.SelectionStart = 0; works so that tb1 shows the string from the beginning, and moves on to highlight the text in the next textbox. But if I press nothing before pressing Up, Down, Tab, or Enter, tb1 keeps the string as it was when it was highlighted - the beginning cut off, and then moves on to highlight the next box. It completely ignores the tb1.SelectionStart = 0;. Here is what I write for the KeyDown event for tb1:
private void tb1Down(object sender, System.Windows.Forms.KeyEventArgs e) { if ((e.KeyCode == Keys.Tab) || (e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Down) || (e.KeyCode == Keys.Up)) { ...save this and that... tb1.SelectionStart = 0; if (e.KeyCode == Keys.Up) {tb0.SelectionStart = 0; tb0.SelectionLength = tb0.Text.Length; tb0.Focus();} else {tb2.SelectionStart = 0; tb2.SelectionLength = tb2.Text.Length; tb2.Focus();} }
Rather than SelectionStart and Selection length, just use the Select method:
tb1.Select(0, 0);
in the leave event. It should work.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: James |
last post by:
Please help - getting very desperate! Sun, 12 October 2003 05:39
I have PHPDEV 4.2.3 from Firepages.com.au as the upgrade to 4.3.0 did
not work. I also had an abortive download from PHP.NET as...
|
by: Dave Navarro |
last post by:
*** Sorry for the cross-posting, but this is an emergency ***
My wife and I run a small web development company in Port Charlotte,
Florida. We hosted our own clients on our own Windows web...
|
by: Tank |
last post by:
I have had this post up here when i was trying to figure out how to
make leading zeros and have been able to fudge that to work. I am now
have trouble getting the loop that makes the folders to...
|
by: John Flynn |
last post by:
hi all
i'm going to be quick i have an assignment due which i have no idea how to
do. i work full time so i dont have the time to learn it and its due date
has crept up on me ..
As follows:...
|
by: lawrence |
last post by:
We've developed a content management system that we donate to the
public domain (via a Creative Commons declaration) at
www.publicdomainsoftware.org. Our cms has an emphasis on weblogs,
though we...
|
by: JM |
last post by:
Hi all,
Further to my mail yesterday, haven't received much help
and am getting slightly worried !
I am trying to add a block of cells but sadly can't get
excel VBA to exactly read my...
|
by: Sajid |
last post by:
Hello! Experts,
I have the following piece of code in VB.NET that I want to use to
update any records in the database. I would like to use a code as well
as DataGrid to update the records....
|
by: Ladysniper |
last post by:
DESPERATE doesn't begin to describe it.
Can someone PLEASE tell me what is WRONG with this code?
Now..a bit of background. It is a search results page for
http://www.azsoma.info/directory.htm....
|
by: pamelafluente |
last post by:
I am still working with no success on that client/server
problem. I need your help. I will submit simplified versions
of my problem so we can see clearly what is going on.
My model:
A client...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: 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...
|
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: 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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| | |