Hi All..............
I have made an application in C# .NET , in which there is a textbox.
In the textbox I want to insert a dot such that it remains there always
but during runtime ,it should be hidden(invisible)and whatever I enter
in the textbox during execution that content in the textbox should start
after the dot(which remains hidden).
And when someone press backspace or delete key, dot should not be removed And when someone select the whole textbox content,
and try to delete all content, So in that case also dot should not be removed.other content can be removed.
Kindly give some solution...............

Recommended Answers

All 6 Replies

This will put a dot behind the text in the textbox:

string myString = myTextbox.Text + ".";

If you want to update the text real-time you have to declare the string first:

sting myString = "";

doubleclick you textbox control to add the "text_changed" event (or do it manually if you know how)
and put this code in the new event:

myString = myTextbox.Text + ".";

This way the string is always ready to use.
I hope this is what you wanted

EDIT: I see you wanted the dot BEFORE the text, you can simply turn around the order by switching "." with myTextbox.Text

This will put a dot behind the text in the

EDIT: I see you wanted the dot BEFORE the text, you can simply turn around the order by switching "." with myTextbox.Text

No this is not working...........
Actually i have entered the string on runtime, and entered string can be anything..............
I want that when i run the program then in that case one dot(.) is automatically appear in the textbox, but that is hidden for others, and if anyone wants to remove that dot, so that should not be removed.
And if anyone wants to write something in textbox, so he can write but after that dot(.)
That . will be unmovable in every case.
It should remain there but hidden for others
Other string can be removed, accept that dot...........

No this is not working...........
Actually i have entered the string on runtime, and entered string can be anything..............
I want that when i run the program then in that case one dot(.) is automatically appear in the textbox, but that is hidden for others, and if anyone wants to remove that dot, so that should not be removed.
And if anyone wants to write something in textbox, so he can write but after that dot(.)
That . will be unmovable in every case.
It should remain there but hidden for others
Other string can be removed, accept that dot...........

What Pieter888 suggested is correct. Lets break it down:
You want the dot to be at the start of the string.
You dont want it to be visible or editable or movable.
The user will be completely oblivious of its existance.

The only time the dot needs to actually exist under those circumstances is when you process the text in code.
The easiest way to achieve that is to add the dot when you retrieve the text. That way, there is no dot in the textbox. If there is no dot, then the dot ISNT visible and it CANNOT be removed/moved.

When you need to use the contents of the textbox in your code you add the dot there as shown in pieter888's code:

string myText = "." + TextBox1.Text;

Remember to mark the thread as solved if your question has been answered

@xyz12
Well you can also place dot at your end, Ryshad and pieter both suggest right thing for this............

What Pieter888 suggested is correct. Lets break it down:
You want the dot to be at the start of the string.
Remember to mark the thread as solved if your question has been answered

Thanks for your reply.......
Well can you tell me , where i have to use this code, i m bit confused, that where i should use this code.............

Thanks for your reply.......
Well can you tell me , where i have to use this code, i m bit confused, that where i should use this code.............

You use the code when you want to retrieve the string from the textbox. Without seeing your project its hard to say for sure. But as an example; if you had a button, and when the user clicked the button you wanted to do something with the string in the textbox, then you would use the code in the buttons event handler. Basically, any time you want to do something with the string, use the code to add the dot before you use it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.