C#
C#

help

Root Question Message

Olan
Olan12/29/2022
❔ Replace space with Hyphen in a text box as i type

Hi can someone please help i have tried this MyGlobalVarables.ProjectName = textBox1.Text.Replace(" ","-"); but it is not working
AntonC
AntonC12/29/2022
more context
Olan
Olan12/29/2022
Hi i have a textbox on a form i want the text box to replace the space character with a hyphen when i type like (abc-def-123)
AntonC
AntonC12/29/2022
well then set the text property on the textbox
AntonC
AntonC12/29/2022
you're setting dome global variable
Angius
Angius12/29/2022
Do you just want the output to be with hyphens instead of spaces? or do you want the hyphens to also show in that texbox?
Angius
Angius12/29/2022
If the latter, you'd run your replacing code on input
Angius
Angius12/29/2022
TextBox.Text = TextBox.Text.Replace(' ', '-');
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy