Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drawing string question

Status
Not open for further replies.

vladibo

Programmer
Sep 14, 2003
161
CA
I am comming in Windows programming from Web and here I met a strange problem:

- When I draw string on my TabPage like this:

int height = 50;
Graphics* gr = this->introductionTab->CreateGraphics();
RectangleF drawRectangle = RectangleF( 0, 10, this->tabControl->Width, height);
StringFormat* drawFormat = new StringFormat();
drawFormat->Alignment = StringAlignment::Center;
gr->DrawString(this->myString,new System::Drawing::Font(S"Verdana", 12, FontStyle::Bold),
Brushes::Black,drawRectangle,drawFormat);

If variable this->myString contains text that can be one line or many lines how can I get the real height? I mean that I set the height in my variable int height, but I would like to have height dynamicly generated by the length of the string. Is it possible to put somehow text on the stage and do not warry about how it is going to fit? What objects shall I use to perform that?

Thank you.
 
Or shall I use RichTextBox to display text with different formats? But I want just I text with headers as I would use in web <h3></h3> and <p></p>
 
Hi again,

I just found that I can do this with Label component, while setting
this->myLabel->Dock = DockStyle::Fill;

However if you know more smarter way of handling the different length of dynamic text, I will be glad to hear it :)
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top