FontDialog.Apply 이벤트
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
글꼴 대화 상자의 적용 단추를 클릭하면 발생합니다.
public:
event EventHandler ^ Apply;
public event EventHandler Apply;
public event EventHandler? Apply;
member this.Apply : EventHandler
Public Custom Event Apply As EventHandler
이벤트 유형
예제
다음 코드 예제를 사용 하 여 보여 줍니다.MinSize는 ShowEffects , MaxSize및 FontMustExist 멤버 및 이벤트를 처리 합니다Apply. 이 예제를 실행하려면 다음 코드를 명명된 와 라는 Button1
FontDialog1
가 포함된 양식에 FontDialogButton 붙여넣습니다.
void Button1_Click( System::Object^ sender, System::EventArgs^ e )
{
// Set FontMustExist to true, which causes message box error
// if the user enters a font that does not exist.
FontDialog1->FontMustExist = true;
// Associate the method handling the Apply event with the event.
FontDialog1->Apply += gcnew System::EventHandler( this, &Form1::FontDialog1_Apply );
// Set a minimum and maximum size to be
// shown in the FontDialog.
FontDialog1->MaxSize = 32;
FontDialog1->MinSize = 18;
// Show the Apply button in the dialog.
FontDialog1->ShowApply = true;
// Do not show effects such as Underline
// and Bold.
FontDialog1->ShowEffects = false;
// Save the existing font.
System::Drawing::Font^ oldFont = this->Font;
//Show the dialog, and get the result
System::Windows::Forms::DialogResult result = FontDialog1->ShowDialog();
// If the OK button in the Font dialog box is clicked,
// set all the controls' fonts to the chosen font by calling
// the FontDialog1_Apply method.
if ( result == ::DialogResult::OK )
{
FontDialog1_Apply( this->Button1, gcnew System::EventArgs );
}
// If Cancel is clicked, set the font back to
// the original font.
else
// If Cancel is clicked, set the font back to
// the original font.
if ( result == ::DialogResult::Cancel )
{
this->Font = oldFont;
System::Collections::IEnumerator^ myEnum = this->Controls->GetEnumerator();
while ( myEnum->MoveNext() )
{
Control^ containedControl = safe_cast<Control^>(myEnum->Current);
containedControl->Font = oldFont;
}
}
}
// Handle the Apply event by setting all controls' fonts to
// the chosen font.
void FontDialog1_Apply( Object^ sender, System::EventArgs^ e )
{
this->Font = FontDialog1->Font;
System::Collections::IEnumerator^ myEnum1 = this->Controls->GetEnumerator();
while ( myEnum1->MoveNext() )
{
Control^ containedControl = safe_cast<Control^>(myEnum1->Current);
containedControl->Font = FontDialog1->Font;
}
}
private void Button1_Click(System.Object sender, System.EventArgs e)
{
// Set FontMustExist to true, which causes message box error
// if the user enters a font that does not exist.
FontDialog1.FontMustExist = true;
// Associate the method handling the Apply event with the event.
FontDialog1.Apply += new System.EventHandler(FontDialog1_Apply);
// Set a minimum and maximum size to be
// shown in the FontDialog.
FontDialog1.MaxSize = 32;
FontDialog1.MinSize = 18;
// Show the Apply button in the dialog.
FontDialog1.ShowApply = true;
// Do not show effects such as Underline
// and Bold.
FontDialog1.ShowEffects = false;
// Save the existing font.
System.Drawing.Font oldFont = this.Font;
//Show the dialog, and get the result
DialogResult result = FontDialog1.ShowDialog();
// If the OK button in the Font dialog box is clicked,
// set all the controls' fonts to the chosen font by calling
// the FontDialog1_Apply method.
if (result == DialogResult.OK)
{
FontDialog1_Apply(this.Button1, new System.EventArgs());
}
// If Cancel is clicked, set the font back to
// the original font.
else if (result == DialogResult.Cancel)
{
this.Font = oldFont;
foreach ( Control containedControl in this.Controls)
{
containedControl.Font = oldFont;
}
}
}
// Handle the Apply event by setting all controls' fonts to
// the chosen font.
private void FontDialog1_Apply(object sender, System.EventArgs e)
{
this.Font = FontDialog1.Font;
foreach ( Control containedControl in this.Controls )
{
containedControl.Font = FontDialog1.Font;
}
}
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
' Set FontMustExist to true, which causes message box error
' if the user enters a font that does not exist.
FontDialog1.FontMustExist = True
' Set a minimum and maximum size to be
' shown in the FontDialog.
FontDialog1.MaxSize = 32
FontDialog1.MinSize = 18
' Show the Apply button in the dialog.
FontDialog1.ShowApply = True
' Do not show effects such as Underline
' and Bold.
FontDialog1.ShowEffects = False
' Save the existing font.
Dim oldFont As System.Drawing.Font = Me.Font
' Show the dialog and save the result.
Dim result As DialogResult = FontDialog1.ShowDialog()
' If The OK button in the Font dialog box is clicked,
' set all the controls' fonts to the chosen font by
' calling the FontDialog1_Apply method.
If result = DialogResult.OK Then
FontDialog1_Apply(Me.Button1, New System.EventArgs)
' If the Cancel button is clicked, set the controls'
' fonts back to the original font.
ElseIf (result = DialogResult.Cancel) Then
Dim containedControl As Control
For Each containedControl In Me.Controls
containedControl.Font = oldFont
Next
End If
End Sub
' Handle the Apply event by setting all controls' fonts to
' the chosen font.
Private Sub FontDialog1_Apply(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles FontDialog1.Apply
Me.Font = FontDialog1.Font
Dim containedControl As Control
For Each containedControl In Me.Controls
containedControl.Font = FontDialog1.Font
Next
End Sub
설명
적용 단추를 클릭할 때마다 다른 Apply 이벤트가 발생합니다.
이벤트 처리에 대한 자세한 내용은 이벤트 처리 및 발생 을 참조하십시오.
적용 대상
추가 정보
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET