473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

am desperate, still need help

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
Dec 15 '05 #1
4 1303
KH
>> 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

Dec 15 '05 #2

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.

Dec 15 '05 #3
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.

Dec 15 '05 #4
melanieab wrote:

Hi Melanie,

Just add

((TextBox)sender).Select(0,0);

to the Leave event of the textbox.
-- Robert Kozak
www.TheArtOfProgrammingWith.net

Dec 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
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...
2
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...
5
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...
5
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:...
2
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...
1
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...
1
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....
7
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....
16
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
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...
0
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...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
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...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.