Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

i have written get set property for a textbox,i want to assign value to the property of textbox but it should not be displayed in that textbox,can this be done?
this is for windows form application

eg:-

if MYtext is property for textbox1;
i will assign value to it Mytext=3;
it should not be displayed in that textbox.

Regards,
-G-
Posted
Comments
Pravin Patil, Mumbai 13-Oct-11 6:38am    
Do you mean, you do not this property to be displayed in Properties window..?
girish sp 13-Oct-11 6:40am    
i dont want the value to be displayed in textbox back,

If you do not want the value to be displayed and then use the "Tag" property to hold the value temperavorily

Assign the value as follows

txtFind.Tag = "1233";



If you want to show the value

txtFind.Text = txtFind.Tag.ToString() ;



if you want to hide
txtFind.Text = "" ;



Not sure, the length of the data the "Tag" property can hold.....just do a google on this for the safe side or some one comment on this
 
Share this answer
 
v2
Comments
girish sp 13-Oct-11 8:44am    
thanks Bala selvanayagam,for this hint..length is not a problem for me as my text max length is 3 digits,i will see if this works for me.
johannesnestler 13-Oct-11 9:18am    
Yes this is the way to go. Tag is just a reference so no problem with length. If you need more comfort derive a special TextBox from Textbox and add a string variable/property. It wouldn't make any sense to have a textbox with assigned text which is not shown (you could do that by setting the foreground (color) property to same as the background)
Bala Selvanayagam 13-Oct-11 9:50am    
Thanks for the additional info johannesnestler
If you make visible option to false, your textbox will not be visible too. If you assign a password char in the properties window, that char will be visible instead of your value.

example: actual value: xyz
textbox shows: ***
 
Share this answer
 
Comments
girish sp 13-Oct-11 8:15am    
i know that ,but i want to know is there any way to hide only text not the control??
A. Duman 13-Oct-11 8:35am    
If you don't want it to be displayed then there is no point assigning a value to it. Can't you assign the value to another variable and use it from there?
You can make a visible option in textbox property to false in visual studio this will not make your value echo in the text box.
 
Share this answer
 
Comments
girish sp 13-Oct-11 6:37am    
could you please be more clear?the visible option in textbox property makes the control visibile ,

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