473,407 Members | 2,320 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,407 software developers and data experts.

spacebar question

hi all,
is there a way to eliminate a 'space character' (the space bar being
pressed) from the beginning of a line?

eg:
hello
as opposed to
hello

thanks in advance


Feb 9 '08 #1
2 1168
If you are meaning can you remove it once it is held in a string, then yes.

string s = " hello";
s = s.Trim();

If you mean in a textbox then use the Trim method on the Text property. You
will need to move the cursor afterwards so that the user isn't surprised.
Alternatively, use the KeyDown event, check for space and the selection
being at the beginning of the text box and mark it handled so the space
isn't added. You will still need to check for pasting in a space from the
clipboard though.

--

BlackWasp
www.blackwasp.co.uk
"Rob Eventine" <bt****@ntlworld.comwrote in message
news:AI*****************@newsfe3-win.ntli.net...
hi all,
is there a way to eliminate a 'space character' (the space bar being
pressed) from the beginning of a line?

eg:
hello
as opposed to
hello

thanks in advance

Feb 10 '08 #2
"BlackWasp" <nospam@please>'s wild thoughts were released on
Sun, 10 Feb 2008 02:08:23 -0000 bearing the following fruit:
>If you are meaning can you remove it once it is held in a string, then yes.

string s = " hello";
s = s.Trim();
s.TrimStart would be more accurate. Although I doubt
trailing spaces are useful.

J
>If you mean in a textbox then use the Trim method on the Text property. You
will need to move the cursor afterwards so that the user isn't surprised.
Alternatively, use the KeyDown event, check for space and the selection
being at the beginning of the text box and mark it handled so the space
isn't added. You will still need to check for pasting in a space from the
clipboard though.
--
Jan Hyde

https://mvp.support.microsoft.com/profile/Jan.Hyde
Feb 18 '08 #3

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

Similar topics

1
by: julio | last post by:
I noticed that pressing spacebar when a listbox has the focus scrolls the listbox to the first selected item. I'm intercepting the spacebar press event at form level for stopping and starting...
2
by: L Mehl | last post by:
Hello -- Sometimes the code editor ignores the spacebar, and requires me to cursor through the line, after entering it, and hit the spacebar where I need a space. Has anyone experienced this?...
16
by: MLH | last post by:
In Access 97 and Access 2.0 applications, if a command button has the focus, the spacebar will 'PRESS" the key. How does one go about disabling this annoying BEATURE?
3
by: Jason Kyle Baginski | last post by:
Here's a little test app to demonstrate a problem I'm having. It creates four buttons, each one with the different FlatStyle types available. Three of them behave exactly the same way(and the...
3
by: dawn | last post by:
Hi, does anyone know how to catch the spacebar with a keypress event.... if (e.KeyChar == ????) thanks.
0
by: Bruce D | last post by:
I have three checkboxes lined up in a row on the dreaded datagrid. I have used the mouseup event to control whether or not the user can select a given box (i.e they can only select one box and...
11
by: Bookham Measures | last post by:
Hello As above, my Ctrl + Spacebar for intellisense is not working in VI 6.0. I have checked keyboard assignments and Ctrl + Space is listed for Edit -> CompleteWord. I added Ctrl + Shift +...
1
by: PARITOSH CHANDRA DEY | last post by:
Hi When Spacebar Click Then See The All Item ? What Is The Coding? Paritosh
5
by: prp | last post by:
Hi all, I have a problem in regularexpressionvalidator. I need that user can not enter any spacebar into the textbox.
1
by: eben12 | last post by:
Hi guys! I'm currently building web application that make use of the spacebar and I need to disable the automatic pagedown that is taking place when pressing the spacebar. In Firefox, I use the...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.