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 1291
>> 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: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| | |