Reputation: 1518
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........
Upvotes: 1
Views: 2264
Reputation: 1771
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.
Upvotes: 2
Reputation: 18013
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.
Upvotes: 2
Reputation: 176906
formMain.ActiveForm.Text += " " + name;
may do your task easily
Upvotes: 4