I have tried like this for adding secondary text to title bar of windows form
formMain.ActiveForm.Text = name;
<pre>
+--+---------------------------------------+----------+
| | Main window title [text] | _ O x |
+--+---------------------------------------+----------+
| |
开发者_如何转开发...
I want to add the text like above mentioned image .but it does not working properly
but my problem is it will replaces the actual text in title bar with above secondary text . I don't want like this , I want to add the text to formain title bar on right hand side with out changing the actual text..
can any one help on this........
formMain.ActiveForm.Text += " " + name;
may do your task easily
I think you are going to need to measure the form, and work out how many whitespace characters you need to insert in between the current form text, and the text you need to add to the right hand side.
You would then add your text to the current title.
eg:
string rightHandText = "[text]";
string whiteSpace = string.Empty.PadLeft( (your calculation for whitespace), ' ');
formMain.Text += String.Format("{0}{1}", whiteSpace, righHandText);
Note the += when setting the form.Text, this adds to the text rather than replacing it.
You can try
formMain.ActiveForm.Text += " " + name;
But this is dirty and undynamic.
i don't know any way you can set the second text with right alignment. If you really want so, I think you have to create a custom Window by your own.
this.Text += " text you want to add";
精彩评论