StringFormat Constructor (StringFormatFlags)
.NET Framework (current version)
Initializes a new StringFormat object with the specified StringFormatFlags enumeration.
Assembly: System.Drawing (in System.Drawing.dll)
Parameters
- options
-
Type:
System.Drawing::StringFormatFlags
The StringFormatFlags enumeration for the new StringFormat object.
The following code example demonstrates the following members:
This example is designed to be used with Windows Forms. Paste the code into a form and call the ShowLineAndAlignment method when handling the form's Paint event, passing e as PaintEventArgs.
private: void ShowLineAndAlignment( PaintEventArgs^ e ) { // Construct a new Rectangle . Rectangle displayRectangle = Rectangle(Point(40,40),System::Drawing::Size( 80, 80 )); // Construct 2 new StringFormat objects StringFormat^ format1 = gcnew StringFormat( StringFormatFlags::NoClip ); StringFormat^ format2 = gcnew StringFormat( format1 ); // Set the LineAlignment and Alignment properties for // both StringFormat objects to different values. format1->LineAlignment = StringAlignment::Near; format1->Alignment = StringAlignment::Center; format2->LineAlignment = StringAlignment::Center; format2->Alignment = StringAlignment::Far; // Draw the bounding rectangle and a string for each // StringFormat object. e->Graphics->DrawRectangle( Pens::Black, displayRectangle ); e->Graphics->DrawString( "Showing Format1", this->Font, Brushes::Red, displayRectangle, format1 ); e->Graphics->DrawString( "Showing Format2", this->Font, Brushes::Red, displayRectangle, format2 ); }
.NET Framework
Available since 1.1
Available since 1.1
Show: