Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi all,

I am working on Windows based application,My Requirement is some part of the textbox control should be read only .Rest of of field should be he can enter.

Example:

contentSetName(Shoud be ReadOnly).ProcessName(User ll enter ) In one Textbox.


Please Help me.
Posted
Comments
V!jAy pAnT 11-Jul-12 6:59am    
try this ........
contentSetName.enable=false;

----------
contentSetName should be textbox id....
jagadeesh123qqq 11-Jul-12 7:02am    
Thanks for your Reply. ContentSetName is Text in TextBox usre should not able edit this text but after .(Dot) He can able to edit

In Above Example he can edit only the ProcessName text

You should add a validation on all possible points where user can change text, like in KeyUp and intercept paste events. But you can find a proper masked edit control and customize it a little bit to fit your needs.
Start here:
Custom Controls Library (MaskEdit, Statusbar with Progress Panel, and more)[^]
Extend the Textbox Control to Validate Against Regular Expressions[^]
http://msdn.microsoft.com/en-us/library/1fkc1cz6[^]
 
Share this answer
 
v2
It is a little difficult and personally i do not not recommended what I am about to do now. but if you still have to do it them do it like this:

1. handle textBox2_TextChanged event
2. have the Text property of textbox set to "contentSetName."
3. then have this code:

C#
private void textBox2_TextChanged(object sender, EventArgs e)
       {
           string newtext = textBox2.Text.Replace("contentSetName.", "");

           textBox2.Text = "contentSetName." + newtext;
       }


Note: The better way could be to use a maskedtextbox instead. think about that too.
 
Share this answer
 
v3
The better solution will be

define a start and end position for your textbox. then after in keypress event if the key is pressed on the defined area then cancel the keyprees...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900