StringFormat.ToString 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
이 StringFormat 개체를 사람이 인식할 수 있는 문자열로 변환합니다.
public:
override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String
반환
이 StringFormat 개체의 문자열 표시입니다.
예제
다음 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 매개 변수 Paint 인 가 필요합니다.PaintEventArgse
코드는 다음 작업을 수행합니다.
개체를 StringFormat 문자열로 변환합니다.
문자열을 그립니다.
개체의 StringFormat 일부 속성을 변경합니다.
문자열을 그립니다. 개체의 속성이 변경되었으므로 문자열이 StringFormat 달라집니다.
void ToStringExample( PaintEventArgs^ e )
{
Graphics^ g = e->Graphics;
SolidBrush^ blueBrush = gcnew SolidBrush( Color::FromArgb( 255, 0, 0, 255 ) );
System::Drawing::Font^ myFont = gcnew System::Drawing::Font( "Times New Roman",14 );
StringFormat^ myStringFormat = gcnew StringFormat;
// String variable to hold the values of the StringFormat object.
String^ strFmtString;
// Convert the string format object to a string (only certain information
// in the object is converted) and display the string.
strFmtString = myStringFormat->ToString();
g->DrawString( String::Format( "Before changing properties: {0}", myStringFormat ), myFont, blueBrush, 20, 40 );
// Change some properties of the string format
myStringFormat->Trimming = StringTrimming::None;
myStringFormat->FormatFlags = (StringFormatFlags)(StringFormatFlags::NoWrap | StringFormatFlags::NoClip);
// Convert the string format object to a string and display the string.
// The string will be different because the properties of the string
// format have changed.
strFmtString = myStringFormat->ToString();
g->DrawString( String::Format( "After changing properties: {0}", myStringFormat ), myFont, blueBrush, 20, 70 );
}
public void ToStringExample(PaintEventArgs e)
{
Graphics g = e.Graphics;
SolidBrush blueBrush = new SolidBrush(Color.FromArgb(255, 0, 0, 255));
Font myFont = new Font("Times New Roman", 14);
StringFormat myStringFormat = new StringFormat();
// String variable to hold the values of the StringFormat object.
string strFmtString;
// Convert the string format object to a string (only certain information
// in the object is converted) and display the string.
strFmtString = myStringFormat.ToString();
g.DrawString("Before changing properties: " + myStringFormat,
myFont, blueBrush, 20, 40);
// Change some properties of the string format
myStringFormat.Trimming = StringTrimming.None;
myStringFormat.FormatFlags = StringFormatFlags.NoWrap
| StringFormatFlags.NoClip;
// Convert the string format object to a string and display the string.
// The string will be different because the properties of the string
// format have changed.
strFmtString = myStringFormat.ToString();
g.DrawString("After changing properties: " + myStringFormat,
myFont, blueBrush, 20, 70);
}
Public Sub ToStringExample(ByVal e As PaintEventArgs)
Dim g As Graphics = e.Graphics
Dim blueBrush As New SolidBrush(Color.FromArgb(255, 0, 0, 255))
Dim myFont As New Font("Times New Roman", 14)
Dim myStringFormat As New StringFormat
' String variable to hold the values of the StringFormat object.
Dim strFmtString As String
' Convert the string format object to a string (only certain
' information in the object is converted) and display the string.
strFmtString = myStringFormat.ToString()
g.DrawString("Before changing properties: ", myFont, blueBrush, _
20, 40, myStringFormat)
' Change some properties of the string format.
myStringFormat.Trimming = StringTrimming.None
myStringFormat.FormatFlags = StringFormatFlags.NoWrap Or _
StringFormatFlags.NoClip
' Convert the string format object to a string and display the
' string. The string will be different because the properties of
' the string format have changed.
strFmtString = myStringFormat.ToString()
g.DrawString("After changing properties: ", myFont, blueBrush, _
20, 70, myStringFormat)
End Sub
설명
속성 값 FormatFlags 만 변환됩니다.
적용 대상
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기