102. 글꼴대화상자(FontDialog) / 색상대화상자(ColorDialog)
==> MainForm.cs
// 컨트롤 - 대화상자 - 폰트
private void miFont_Click(object sender, EventArgs e)
{
MyWinForms.Controls.FrmFontDialog ffd = new MyWinForms.Controls.FrmFontDialog();
ffd.MdiParent = this;
ffd.Show();
}
==============================================================================================
==> FrmFontDialog.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MyWinForms.Controls
{
public partial class FrmFontDialog : Form
{
public FrmFontDialog()
{
InitializeComponent();
}
private void btnFont_Click(object sender, EventArgs e)
{
// 폰트창을 열고,
DialogResult dr =
this.fdFont.ShowDialog();
// 확인 버튼 누르면, 변경
if (dr == DialogResult.OK)
{
txtFont.Font = fdFont.Font;
}
}
private void btnColor_Click(object sender, EventArgs e)
{
// 색상창 열고,
if (cdColor.ShowDialog() != DialogResult.Cancel)
{
txtFont.ForeColor = cdColor.Color; // 글꼴색 변경
}
}
}
}
< 실행결과 >
-->"글꼴"버튼을 눌렀을 때 화면( "글꼴"창 왼쪽 아래 있는 "색"은 FrmFontDialog.cs [디자인]에서 FontDialog의 속성 중 "ShowColor -> True"로 바꿔줘야 나타난다._
--> "색상"버튼을 눌렀을 때 화면