編輯

共用方式為


StringFormat Class

Definition

Encapsulates text layout information (such as alignment, orientation and tab stops) display manipulations (such as ellipsis insertion and national digit substitution) and OpenType features. This class cannot be inherited.

public ref class StringFormat sealed : MarshalByRefObject, ICloneable, IDisposable
public sealed class StringFormat : MarshalByRefObject, ICloneable, IDisposable
type StringFormat = class
    inherit MarshalByRefObject
    interface ICloneable
    interface IDisposable
Public NotInheritable Class StringFormat
Inherits MarshalByRefObject
Implements ICloneable, IDisposable
Inheritance
StringFormat
Implements

Remarks

Many common formats are provided through the StringFormatFlags enumeration. StringFormat objects can be changed.

Note

In .NET 6 and later versions, the System.Drawing.Common package, which includes this type, is only supported on Windows operating systems. Use of this type in cross-platform apps causes compile-time warnings and run-time exceptions. For more information, see System.Drawing.Common only supported on Windows.

Constructors

StringFormat()

Initializes a new StringFormat object.

StringFormat(StringFormat)

Initializes a new StringFormat object from the specified existing StringFormat object.

StringFormat(StringFormatFlags, Int32)

Initializes a new StringFormat object with the specified StringFormatFlags enumeration and language.

StringFormat(StringFormatFlags)

Initializes a new StringFormat object with the specified StringFormatFlags enumeration.

Properties

Alignment

Gets or sets horizontal alignment of the string.

DigitSubstitutionLanguage

Gets the language that is used when local digits are substituted for western digits.

DigitSubstitutionMethod

Gets the method to be used for digit substitution.

FormatFlags

Gets or sets a StringFormatFlags enumeration that contains formatting information.

GenericDefault

Gets a generic default StringFormat object.

GenericTypographic

Gets a generic typographic StringFormat object.

HotkeyPrefix

Gets or sets the HotkeyPrefix object for this StringFormat object.

LineAlignment

Gets or sets the vertical alignment of the string.

Trimming

Gets or sets the StringTrimming enumeration for this StringFormat object.

Methods

Clone()

Creates an exact copy of this StringFormat object.

CreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose()

Releases all resources used by this StringFormat object.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
Finalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLifetimeService()
Obsolete.

Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetTabStops(Single)

Gets the tab stops for this StringFormat object.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService()
Obsolete.

Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
SetDigitSubstitution(Int32, StringDigitSubstitute)

Specifies the language and method to be used when local digits are substituted for western digits.

SetMeasurableCharacterRanges(CharacterRange[])

Specifies an array of CharacterRange structures that represent the ranges of characters measured by a call to the MeasureCharacterRanges(String, Font, RectangleF, StringFormat) method.

SetTabStops(Single, Single[])

Sets tab stops for this StringFormat object.

ToString()

Converts this StringFormat object to a human-readable string.

Applies to

See also