using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace C_UsingControls { public partial class MainForm : Form { void ChangeFont() { if (cboFont.SelectedIndex < 0) return; FontStyle style = FontStyle.Regular; if (chkBold.Checked) style |= FontStyle.Bold; if (chkitalic.Checked) style |= FontStyle.Italic; txtSampleText.Font = new Font((string)cboFont.SelectedItem, 10, style); } public MainForm() { InitializeComponent(); } private void InitializeComponent() { this.GroupBox_DG = new System.Windows.Forms.GroupBox(); this.cboFont = new System.Windows.Forms.ComboBox(); this.lblFont = new System.Windows.Forms.Label(); this.chkBold = new System.Windows.Forms.CheckBox(); this.chkitalic = new System.Windows.Forms.CheckBox(); this.txtSampleText = new System.Windows.Forms.TextBox(); this.GroupBox_DG.SuspendLayout(); this.SuspendLayout(); // // GroupBox_DG // this.GroupBox_DG.Controls.Add(this.txtSampleText); this.GroupBox_DG.Controls.Add(this.chkitalic); this.GroupBox_DG.Controls.Add(this.chkBold); this.GroupBox_DG.Controls.Add(this.lblFont); this.GroupBox_DG.Controls.Add(this.cboFont); this.GroupBox_DG.Location = new System.Drawing.Point(12, 12); this.GroupBox_DG.Name = "GroupBox_DG"; this.GroupBox_DG.Size = new System.Drawing.Size(260, 238); this.GroupBox_DG.TabIndex = 0; this.GroupBox_DG.TabStop = false; this.GroupBox_DG.Text = "ComboBox, CheckBox, TextBox"; // // cboFont // this.cboFont.FormattingEnabled = true; this.cboFont.Location = new System.Drawing.Point(59, 26); this.cboFont.Name = "cboFont"; this.cboFont.Size = new System.Drawing.Size(68, 20); this.cboFont.TabIndex = 1; // // lblFont // this.lblFont.AutoSize = true; this.lblFont.Location = new System.Drawing.Point(15, 29); this.lblFont.Name = "lblFont"; this.lblFont.Size = new System.Drawing.Size(37, 12); this.lblFont.TabIndex = 2; this.lblFont.Text = "Font :"; // // chkBold // this.chkBold.AutoSize = true; this.chkBold.Location = new System.Drawing.Point(142, 29); this.chkBold.Name = "chkBold"; this.chkBold.Size = new System.Drawing.Size(48, 16); this.chkBold.TabIndex = 3; this.chkBold.Text = "±½°Ô"; this.chkBold.UseVisualStyleBackColor = true; // // chkitalic // this.chkitalic.AutoSize = true; this.chkitalic.Location = new System.Drawing.Point(194, 28); this.chkitalic.Name = "chkitalic"; this.chkitalic.Size = new System.Drawing.Size(60, 16); this.chkitalic.TabIndex = 4; this.chkitalic.Text = "ÀÌÅÚ¸¯"; this.chkitalic.UseVisualStyleBackColor = true; // // txtSampleText // this.txtSampleText.Location = new System.Drawing.Point(17, 69); this.txtSampleText.Name = "txtSampleText"; this.txtSampleText.Size = new System.Drawing.Size(224, 21); this.txtSampleText.TabIndex = 5; this.txtSampleText.Text = "Hello, C#"; // // MainForm // this.ClientSize = new System.Drawing.Size(284, 262); this.Controls.Add(this.GroupBox_DG); this.Name = "MainForm"; this.Text = "Control Test"; this.Load += new System.EventHandler(this.MainForm_Load); this.GroupBox_DG.ResumeLayout(false); this.GroupBox_DG.PerformLayout(); this.ResumeLayout(false); } private GroupBox GroupBox_DG; private ComboBox cboFont; private TextBox txtSampleText; private CheckBox chkitalic; private CheckBox chkBold; private Label lblFont; private void MainForm_Load(object sender, EventArgs e) { var Fonts = FontFamily.Families; foreach (FontFamily V_font in Fonts) cboFont.Items.Add(V_font.Name); } private void cboFont_SelectedIndexChanged(object sender, EventArgs e) { ChangeFont(); } private void chkBold_CheckedChanged(object sender, EventArgs e) { ChangeFont(); } private void chkitalic_CheckedChanged(object sender, EventArgs e) { ChangeFont(); } } }