开发者

text box read only

i create form with TextBox on it. Text box have a ReadOnly true p开发者_如何学编程ropertiy. when i add text to text box. all text inside the text box is selected. how i can rid that. i tried to change value of SelectionLength, SelectionStart, SelectedText properties but that did not help. I Use VC# 2008 express.


After you set the text, clear the selection:

textBox1.Text += "String" + Environment.NewLine + "String";
textBox1.Select(0, 0);

SelectionLength will be 0 until after the TextBox receives focus, which explains why setting that property did not work.


try

textbox1.Enabled = false;


Setting the ReadOnly property to True should be enough. Maybe you have some other code that selects the text you programtically put into the textbox.


I need a little more information from you. Are you trying to disable the textbox (Read-only)? You can say "Textbox1.enabled = false"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜