Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to remove all chars after a space in Textbox

My Problem is that my Users sometimes did mistakes and i want to avoid this by removing the splitted part of the string automatically.

i dont want to combine the splitted string, i just want to remove all what is written after the space.

Should look like this:
enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

All what i selected should be automatically removed after i press the Button to Save/Confirm.

>Solution :

Source: Removing everything after the first " " in a string? (space)

It would be simpler to do a string.Split():

string input = "some:kind of string   that I want      totrim please."; 
input = input.Split()[0];
//input = "some:kind" now

So it should look something like this, based on what are you working on (I suppose WPF)

string inputText = txtInput.Text;
inputText.Split()[0];
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading