주의 : 자칫 폼을 죽일 수 있음. 14 - 5 - 8 일 작성한 Thread 예제 사용 가능 thread 사용에는 form 내부의 control에 접근하기 어려운 점들이 있다. progress Bar 나 text Box 등 접근해서 처리했으면 하는 것들이 있는데 이를 해결하기 위해 C#에 존재하는 것이 BackGroundWorker 이다. Thread 와 동일하게 Work, Complete 가 존재하며, 특별히 progressChanged 라는 것을 통해서 Progress Bar 를 좀 더 편하게 처리할 수 있다. BackgroundWorker backgroundWorker1 = new BackgroundWorker(); public Form1() { InitializeComponent(); backg..
여러가지 방식이 존재하나 그 중 유용한 두 가지 방식입니다. 1. color 의 이름을 직접 알 고 있을때. private void Set_Color; { textBox1.BackColor = color.Red; textBox2.BackColor = color.Blue; } 위와 같이 정확한 명칭을 알고 있을 때는 위와 같이 하면 됩니다. C#의 경우 사용자 지정, web, system 의 분류로 나뉘어져 있어서 보기 편하게 되어 있기도 합니다. 2. hex 값을 알고 있을 때, private void Set_Color; { textBox1.BackColor = ColorTranslator.FromHtml("#007FDD"); } 위와 같이 ColorTranslator 를 이용해서 헥사 코드를 직접 찍는..
방식은 1. 특정 창에 마우스를 down 이벤트를 주었을 때, point 값을 가져오고 2. 마우스를 이동 시 창의 location 의 위치를 변경하는 것입니다. 많은 방법들이 있지만, 제일 심플하게 사용할 수 있는 소스인 것 같습니다. private Point mousePoint; private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { mousePoint = new Point(e.X, e.Y); } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if ((e.Button & MouseButtons.Left) == MouseButtons.Left) { Loca..
ListView 에는 check box 를 추가하는 기능이 있습니다. 그중 check 된 것만 골라내야 하는 경우가 생기는데 전체 리스트를 돌면서 check box 가 true 인 것을 찾는 것이 아닌 체크된 항목만 끄집어 내는 방법이 있습니다. 방법은 listView1 의 checkeditems 를 찾고, ListviewItem 에 하나씩 넣은 다음 처리하는 것입니다. foreach (ListViewItem item in listView1.CheckedItems) { textBox1.AppendText( item.SubItems[0].Text + "\n" ); item.BackColor = Color.Aquamarine; } 추가 : item.BackColor 는 해당 라인 색 변경에 사용됩니다. 출처..
C# 같은 경우 해당 폼이 완전 load 가 완료된 시점을 찾기가 어렵다. 그런 메써드가 있는 것도 아니고.. 그래서 검색하다가 나온 것은 임시 방편으로 사용할만한 것인데, Application 의 상태가 idle -> 놀고 있다는 것은, 로딩이 완료됐다는 시점을 찾고 그 시점이 됐을 때, 원하는 것을 실행 시키는 것이다. 필자의 경우, 메시지 박스를 통해서 버전체크를 하고, 버전이 다르다면 업데이트를 하겠냐는 메시지 박스를 띄우려고 했는데 Form load 가 다 완료 되기도 전에 메시지 창이 뜨는 오류가 있었다. 그래서 아래와 같은 코드를 사용하게 되었다. public Mainform() { InitializeComponet(); Application.Idle += Check_Version; } pr..
// 원본과, 목적지를 같이 대입 public void CopyFolder (string sourceFolder, string destFolder ) { if (!Directory.Exists(destFolder)) Directory.CreateDirectory(destFolder); string[] files = Directory.GetFiles(sourceFolder); string[] folders = Directory.GetDirectories(sourceFolder); foreach (string file in files) { string name = Path.GetFileName(file); string dest = Path.Combine(destFolder, name); File.Copy(f..
static Timer myTimer = new Timer(); static int alarmCounter = 1; static bool exitFlag = false; private static void timerEventProcessor( object myObject, EventArgs myEventArgs ) { // event 발생시 timer stop myTimer.Stop(); // messageBox 를 이용해서 Yes No 를 판단하고 flag 또는 counter 를 변화 시킵니다. if (MessageBox.Show("Conuinue?", "Count :" + alarmCounter, MessageBoxButtons.YesNo) == DialogResult.Yes) { alarmCount..
using System.Security.Cryptography; private void button1_Click(object sender, EventArgs e) { textBox3.Text = AESEncrypt256(textBox2.Text ); } private void button2_Click(object sender, EventArgs e) { textBox4.Text = AESDecrypt256(textBox3.Text); } public String AESEncrypt256(String InputText ) { string Password = textBox1.Text; RijndaelManaged RijndaelCipher = new RijndaelManaged(); // 입력받은 문자열을 ..
using System.Runtime.InteropServices; namespace test_ini { class Program { // get [DllImport("kernel32")] private static extern int GetPrivateProfileString( string section, string key, string def, StringBuilder retVal, int size, string filePath); // write [DllImport("kernel32")] private static extern long WritePrivateProfileString( string section, string key, string val, string filePath); static..
using System.Reflection; namespace test_versionCheck { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Assembly asm = Assembly.LoadFrom(@"C:\YPM\YPM2013.exe"); AssemblyName name = asm.GetName(); MessageBox.Show( name.Version.ToString() ); } } } using 구문을 보면 reflection( 한 : 반영 ) 이란 namespace를 이용한 것입니다. Assembly..
- Total
- 331,919
- Today
- 0
- Yesterday
- 89
- 알프스목초지1-4
- Joseph Redmon
- 리눅스
- C# 패널
- 자신만의향
- PolyBridge1-4
- DaleEvans
- C# 패널 예제
- PolyBridge1-3
- 믿는다는것
- 알프스목초지1-3
- PolyBridge1-5
- PolyBridge하는법
- 인생의시간
- 알프스목초지1-2
- PolyBridge1-1
- OnlyICan
- 분할작업
- Nina Fedoroff
- 1Day1Sentence
- c#
- 알프스목초지1-1
- 사람의인생
- ted
- PolyBridge
- 좋은글귀
- 알프스목초지1-5
- PolyBridge1-2
- 폴리브릿지
- C# 판넬 예제
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 |
- 2017/08 (4)
