StringFormat Constructores
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Inicializa un nuevo objeto StringFormat.
Sobrecargas
StringFormat() |
Inicializa un nuevo objeto StringFormat. |
StringFormat(StringFormat) |
Inicializa un nuevo objeto StringFormat a partir del objeto StringFormat existente especificado. |
StringFormat(StringFormatFlags) |
Inicializa un nuevo objeto de StringFormat con la enumeración StringFormatFlags especificada. |
StringFormat(StringFormatFlags, Int32) |
Inicializa un nuevo objeto StringFormat con la enumeración StringFormatFlags y el idioma especificados. |
StringFormat()
- Source:
- StringFormat.cs
- Source:
- StringFormat.cs
- Source:
- StringFormat.cs
Inicializa un nuevo objeto StringFormat.
public:
StringFormat();
public StringFormat ();
Public Sub New ()
Comentarios
En la siguiente tabla se muestran los valores iniciales de las propiedades de una instancia de la clase StringFormat.
Propiedad | Valor inicial |
---|---|
FormatFlags | 0 (no se establecen marcas) |
HotkeyPrefix | None |
Se aplica a
StringFormat(StringFormat)
- Source:
- StringFormat.cs
- Source:
- StringFormat.cs
- Source:
- StringFormat.cs
Inicializa un nuevo objeto StringFormat a partir del objeto StringFormat existente especificado.
public:
StringFormat(System::Drawing::StringFormat ^ format);
public StringFormat (System.Drawing.StringFormat format);
new System.Drawing.StringFormat : System.Drawing.StringFormat -> System.Drawing.StringFormat
Public Sub New (format As StringFormat)
Parámetros
- format
- StringFormat
Objeto StringFormat a partir del cual se va a inicializar el nuevo objeto StringFormat.
Excepciones
format
es null
.
Ejemplos
En el ejemplo de código siguiente se muestran los siguientes miembros:
Este ejemplo está diseñado para usarse con Windows Forms. Pegue el código en un formulario y llame al ShowLineAndAlignment
método al controlar el evento del Paint formulario, pasando e
como 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 );
}
private void ShowLineAndAlignment(PaintEventArgs e)
{
// Construct a new Rectangle .
Rectangle displayRectangle =
new Rectangle (new Point(40, 40), new Size (80, 80));
// Construct 2 new StringFormat objects
StringFormat format1 = new StringFormat(StringFormatFlags.NoClip);
StringFormat format2 = new 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, (RectangleF)displayRectangle, format1);
e.Graphics.DrawString("Showing Format2", this.Font,
Brushes.Red, (RectangleF)displayRectangle, format2);
}
Private Sub ShowLineAndAlignment(ByVal e As PaintEventArgs)
' Construct a new Rectangle.
Dim displayRectangle _
As New Rectangle(New Point(40, 40), New Size(80, 80))
' Construct two new StringFormat objects
Dim format1 As New StringFormat(StringFormatFlags.NoClip)
Dim format2 As New 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", Me.Font, Brushes.Red, _
RectangleF.op_Implicit(displayRectangle), format1)
e.Graphics.DrawString("Showing Format2", Me.Font, Brushes.Red, _
RectangleF.op_Implicit(displayRectangle), format2)
End Sub
Se aplica a
StringFormat(StringFormatFlags)
- Source:
- StringFormat.cs
- Source:
- StringFormat.cs
- Source:
- StringFormat.cs
Inicializa un nuevo objeto de StringFormat con la enumeración StringFormatFlags especificada.
public:
StringFormat(System::Drawing::StringFormatFlags options);
public StringFormat (System.Drawing.StringFormatFlags options);
new System.Drawing.StringFormat : System.Drawing.StringFormatFlags -> System.Drawing.StringFormat
Public Sub New (options As StringFormatFlags)
Parámetros
- options
- StringFormatFlags
Enumeración StringFormatFlags para el nuevo objeto StringFormat.
Ejemplos
En el ejemplo de código siguiente se muestran los siguientes miembros:
Este ejemplo está diseñado para usarse con Windows Forms. Pegue el código en un formulario y llame al ShowLineAndAlignment
método al controlar el evento del Paint formulario, pasando e
como 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 );
}
private void ShowLineAndAlignment(PaintEventArgs e)
{
// Construct a new Rectangle .
Rectangle displayRectangle =
new Rectangle (new Point(40, 40), new Size (80, 80));
// Construct 2 new StringFormat objects
StringFormat format1 = new StringFormat(StringFormatFlags.NoClip);
StringFormat format2 = new 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, (RectangleF)displayRectangle, format1);
e.Graphics.DrawString("Showing Format2", this.Font,
Brushes.Red, (RectangleF)displayRectangle, format2);
}
Private Sub ShowLineAndAlignment(ByVal e As PaintEventArgs)
' Construct a new Rectangle.
Dim displayRectangle _
As New Rectangle(New Point(40, 40), New Size(80, 80))
' Construct two new StringFormat objects
Dim format1 As New StringFormat(StringFormatFlags.NoClip)
Dim format2 As New 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", Me.Font, Brushes.Red, _
RectangleF.op_Implicit(displayRectangle), format1)
e.Graphics.DrawString("Showing Format2", Me.Font, Brushes.Red, _
RectangleF.op_Implicit(displayRectangle), format2)
End Sub
Se aplica a
StringFormat(StringFormatFlags, Int32)
- Source:
- StringFormat.cs
- Source:
- StringFormat.cs
- Source:
- StringFormat.cs
Inicializa un nuevo objeto StringFormat con la enumeración StringFormatFlags y el idioma especificados.
public:
StringFormat(System::Drawing::StringFormatFlags options, int language);
public StringFormat (System.Drawing.StringFormatFlags options, int language);
new System.Drawing.StringFormat : System.Drawing.StringFormatFlags * int -> System.Drawing.StringFormat
Public Sub New (options As StringFormatFlags, language As Integer)
Parámetros
- options
- StringFormatFlags
Enumeración StringFormatFlags para el nuevo objeto StringFormat.
- language
- Int32
Valor que indica el idioma del texto.