102. 글꼴대화상자(FontDialog) / 색상대화상자(ColorDialog)
.NET프로그래밍/WinForm 2009. 8. 24. 15:02 |
==> 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"로 바꿔줘야 나타난다._
--> "색상"버튼을 눌렀을 때 화면
'.NET프로그래밍 > WinForm' 카테고리의 다른 글
104. 초간단 노트패드(메모장) 만들기 (0) | 2009.08.24 |
---|---|
103. 파일열기(OpenFileDialog) / 파일저장(SaveFileDialog) / 폴더열기(FolderBrowserDialog) 대화상자 (0) | 2009.08.24 |
101. DialogResult (부모폼과 자식폼의 값 전달) (0) | 2009.08.24 |
100. 그룹박스(GrouBox) (0) | 2009.08.24 |
99. 콤보박스(ComboBox)와 리스트박스(LIstBox) (0) | 2009.08.24 |