C# Windows Forms 글꼴(button, openFileDialog,ToolStripMenuItem) 결과물 글꼴 클릭 시 코드 복사코드 using System.Diagnostics; //외부프로그램 private void 글꼴ToolStripMenuItem1_Click(object sender, EventArgs e) { fontDialog1.ShowDialog(); textBox1.Font = fontDialog1.Font; textBox1.ForeColor = fontDialog1.Color; } C# 2022.01.14
C# Windows Forms 열기(button, openFileDialog, ToolStripMenuItem) 결과 열기 클릭을 하거나 Ctrl+O 입력 시 속성 코드 복사코드 using System.Diagnostics; //외부프로그램 private void 글꼴ToolStripMenuItem_Click(object sender, EventArgs e) { openFileDialog1.InitialDirectory = @"C:\temp"; openFileDialog1.Filter = "텍스트 파일(.txt) | *.txt |한글 파일(.hwp)|*.hwp| 모든 파일(*.*) | *.*"; openFileDialog1.ShowDialog(); foreach (string str in openFileDialog1.FileNames) { textBox1.Text += str; textBox1.Text += "\n.. C# 2022.01.13
C# Windows Forms 폴더탐색기(button, folderBrowserDialog) 결과물 1) 폴더탐색기 버튼 클릭 시 코드 복사코드 using System.Diagnostics; //외부프로그램 private void button5_Click(object sender, EventArgs e) { folderBrowserDialog1.ShowDialog(); textBox1.Text = folderBrowserDialog1.SelectedPath.ToString(); } C# 2022.01.12
C# Windows Forms 인쇄(button, printDialog) 결과 인쇄 버튼 클릭 시 코드 복사코드 using System.Diagnostics; //외부프로그램 using System.Drawing.Printing; //인쇄할 때 필수항목 private void PrintPage(object sender, PrintPageEventArgs e) {//텍스트박스의 텍스트를 출력 내용(PDF같은 이미지)으로 구성하는 동작 string str = textBox1.Text; //택스트박스 내용을 지정 Font f = new Font("굴림", 12, FontStyle.Regular); e.Graphics.DrawString(str, f, Brushes.Red, 50, 30); } private void button4_Click(object sender, EventArg.. C# 2022.01.10
C# Windows Forms 미리보기(button, printPreviewDialog) 결과 미리보기 버튼 클릭 시 코드 복사코드 using System.Diagnostics; //외부프로그램 using System.Drawing.Printing; //인쇄할 때 필수항목 private void PrintPage(object sender, PrintPageEventArgs e) {//텍스트박스의 텍스트를 출력 내용(PDF같은 이미지)으로 구성하는 동작 string str = textBox1.Text; //택스트박스 내용을 지정 Font f = new Font("굴림", 12, FontStyle.Regular); e.Graphics.DrawString(str, f, Brushes.Red, 50, 30); } private void button3_Click(object sender, EventA.. C# 2022.01.09
C# Windows Forms 색상(button, colorDialog) 결과 색상 버튼 클릭 시 코드 복사코드 using System.Diagnostics; //외부프로그램 private void button7_Click(object sender, EventArgs e) { colorDialog1.ShowDialog(); textBox1.BackColor = colorDialog1.Color; } C# 2022.01.08
C# Windows Forms 글꼴(button, fontDialog) 결과 글꼴 버튼 클릭 시 코드 복사코드 using System.Diagnostics; //외부프로그램 private void button2_Click(object sender, EventArgs e) { fontDialog1.ShowDialog(); textBox1.Font = fontDialog1.Font; textBox1.ForeColor = fontDialog1.Color; } C# 2022.01.06
C# Windows Forms 열기(button, openFileDialog ) 결과 폼 실행 1) 버튼 클릭시 콤보박스에도 추가된다. 코드 using System.Diagnostics; //외부프로그램 복사코드 private void button1_Click(object sender, EventArgs e) { openFileDialog1.InitialDirectory = @"C:\temp"; openFileDialog1.Filter = "텍스트 파일(.txt) | *.txt |한글 파일(.hwp)|*.hwp| 모든 파일(*.*) | *.*"; openFileDialog1.ShowDialog(); foreach (string str in openFileDialog1.FileNames) { textBox1.Text += str; textBox1.Text += "\n\n"; combo.. C# 2022.01.04
C# Windows Forms(Resize, Paint, MouseUp) 결과 1) 폼 실행 2) 블록 클릭 시 3) 모두 삭제 버튼 클릭 시 4) 종료시 코드 복사코드 namespace 연습용 { public partial class Form5 : Form { public Form5() { InitializeComponent(); } protected const int xNum = 5; protected const int yNum = 5; protected bool[,] abChecked = new bool[yNum, xNum]; protected int cxBlock, cyBlock; private void Form5_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; Pen pen = new Pen(For.. C# 2022.01.01
C# Windows Forms button_KeyUp 이벤트 결과 -> 실행시 출력 왼쪽 화살표 오른쪽 화살표 위 화살표 아래 화살표 종료시 코드 복사코드 namespace 연습용 { public partial class Form4 : Form { public Form4() { InitializeComponent(); } public int xPt, yPt; public static readonly int MOVE = 20; private void Form4_Load(object sender, EventArgs e) { MessageBox.Show("button_KeyUp 이벤트", "폼 실행"); } private void Form4_FormClosed(object sender, FormClosedEventArgs e) { MessageBox.Show("이벤트 .. C# 2021.12.22