본문 바로가기

c#

[C# .NET] MSFlexGrid 컨트롤에 직접 입력 가능한 기능 만들기 (종목추가/종목삭제) 대충 개념정도만 설명함. [사용법] MSFlexGrid의 여러 셀 중에서 내가 입력을 원하는 셀에 마우스를 클릭하고, 마우스 오른쪽 버튼을 눌러서 "종목추가" 메뉴를 클릭하면 해당 셀에 텍스트 박스가 뜨고 원하는 글자(종목)을 입력 받는다. (입력이 끝난 후) 포커스가 셀을 떠나면 텍스트박스에 입력한 내용을 해당 셀에 저장하게 되고, 텍스트박스의 내용은 지워지며 텍스트 박스는 보이지 않게 된다. 지우고 싶은 셀에 마우스로 클릭한 뒤 마우스 오른쪽 버튼을 눌러 "종목삭제"를 선택하며 해당 셀의 내용은 지워진다. [적용컨트롤] MSFlexGrid1 contextMenuStrip1 textBox1 [코드] //셀에서 커서가 떠날 때 private void MSFlexGrid1_LeaveCell(object s.. 더보기
How to Move the Textbox Control in C# private void button1_Click(object sender, EventArgs e) { this.textBox1.Location = new System.Drawing.Point(2, 3); } public partial class Form1 : Form { int tickX = 0; int tickY = 0; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.textBox1.Location = new System.Drawing.Point(28, 38); } private void button1_Click(object sender, EventArgs e) { te.. 더보기
[C# .NET] BackgroundWorker, ProgressBar 활용 [BackgroundWorker] BackgroundWorker는 별도의 쓰레드에게 일을 시키기 위해 사용하는 클래스. [ProgressBar] ProgressBar는 작업진행이 얼마 되었는지 보여주는 표시바이다. public frmAutoGetList() { InitializeComponent(); bworker.WorkerReportsProgress = true; bworker.WorkerSupportsCancellation = true; bworker.DoWork += new DoWorkEventHandler(bworker_DoWork); bworker.ProgressChanged += new ProgressChangedEventHandler(bworker_ProgressChanged); bwork.. 더보기
[C#] Tray Icon (트래이 아이콘)으로 만들기 프로그램을 종료하지 않고, 숨겨놓고 구동시키고 싶을 때 Tray를 이용하면 된다. 검색]에서 *.ico 파일로 검색하면 많이 나온다.) 그리고 나서 트래이 명령을 줄 버튼( button1 )과 notifyIcon1에 이벤트를 추가하면 된다. //Tray 시키기 private void button1_Click(object sender, System.EventArgs e) { this.Hide(); // 폼을 보이지 않게 한다. alt+tab 시 보이지 않는다. notifyIcon1.Visible = true; // 트레이의 아이콘을 보이게 한다. this.Hide(); this.notifyIcon1.Text ="FileMover is Run"; } //원래대로 돌아오기 private void notifyI.. 더보기
[C#] progress bar 사용하기 The Progressbar class provides progress bar control functionality in the .NET framework. You need progress bars to display the progress of your application or background tasks. There are only three members of the ProgressBar class you should know about. The Maximum, the Minimum, and the Value properties. You create a progress bar control using ProgressBar constructor. this.progressBar1 = new Sys.. 더보기
[C#] 자식창에서 부모창으로 값 넘기는 방법(소스) [첫번째 방법] 1) 부모창에서 자식창을 불러오는 곳에서 public String temp = ""; private void button3_Click(object sender, EventArgs e) { frmParent fChild = new frmParent(); fChild.Owner = this; fChild.ShowDialog(); //fChild.ShowDialog(this); } 2) 자식창에서 값을 넘길 때 private void button1_Click(object sender, EventArgs e) { ((frmParent)(this.Owner)).temp = textBox1.Text; } frmParent(부모창)에서의 temp는 public으로 선언 되어 있어야 frmChild(자.. 더보기
[C#] 콘솔 입출력 코드 namespace ConsoleApplication1 { class Hello { static void Main(string[] args) { string strRead; int i = 0; Console.WriteLine("이름을 넣어주세요 ->"); strRead = Console.ReadLine(); while (strRead.Length != 0) { i++; Console.WriteLine("안녕하세요 ? {0}!!", strRead + "님...."); Console.WriteLine("{0}", i.ToString() + "번째 손님입니다."); Console.Write("이름을 넣어주세요 ->"); strRead = Console.ReadLine(); if (strRead == "q") {.. 더보기
[C#] 파일 쓰기, 복사, 삭제, 이동 class Program { static void Main(string[] args) { string MyWriteFile3 = @"Data.txt"; Console.WriteLine("파일 생성중.... 잠시만 기다리세요."); StreamWriter FileWriter3 = File.CreateText(MyWriteFile3); Console.WriteLine("파일에 데이터 작성중...."); FileWriter3.WriteLine("== File Name = FilePorcess3.txt =="); FileWriter3.WriteLine("안녕하세요!!!"); FileWriter3.WriteLine("수고하세요 저장합니다."); FileWriter3.Close(); Console.WriteLine.. 더보기