가) 초기 셋팅
======================================================
            lst.View = View.Details;
            lst.LabelEdit = false;
            lst.CheckBoxes = true; // 삭제시 사용
            lst.FullRowSelect = true;
            lst.GridLines = true;
            lst.Sorting = SortOrder.Ascending;
======================================================

나) 항목 추가
======================================================
ListViewItem item1 = new ListViewItem(i + "_" + "번호");
item1.SubItems.Add(i + "_" + "장소");
======================================================

다) 항목 삭제
체크박스를 이용하였다.
체크한 항목만 삭제해 보장
======================================================
            int i=0;
            int Count;

            ListView.CheckedListViewItemCollection checkedItems = lst.CheckedItems;
            foreach (ListViewItem item in checkedItems)
            {
                Count = lst.CheckedIndices[i];
                lst.Items.RemoveAt(Count);
            }
======================================================

라) 결론
  간만에 컨트롤을 이용해 보았는데 잘 안돼서 혼났다 역시 코딩은 자주해보고 경험을 많이 쌓아야 하는거 같다. 뭐 다른것도 마찬가지 겠지만...

- WinMain()  함수를 통해 윈도우 응용프로그램이 시작된다.
- 사용자의 입력 이벤트는 모두 메세지로 전환된다.
- 윈도우 운영체제는 이벤트에 따른 메시지를 메시지큐에 추가한다.
- 메인 메시지 루프는 메시지 큐에서 메시지를 꺼내서(GetMessage() 함수) 처리(DispatchMessage()함수)하는 핵심코드이다.
- 윈도우 종료 메시지를 처리하면 메인 메시지 루프가 끝나고 응용 프로그램이 종료된다.

발췌 : Visual C++ 2008 MFC 윈도우 프로그래밍

'객체지향언어 > MFC' 카테고리의 다른 글

콤보박스 초기화 부분에서 CString에 안먹는 바람에 애를 먹어서  (0) 2009.09.28
메모리에서 데이터 관리  (0) 2009.08.23
COM의 등장과 용어  (0) 2009.08.21
MFC 책 목록  (0) 2009.08.05
Visual C++ 구성  (0) 2009.07.29

델리게이트에 이런 강력한 기능은 c#만에 매력인거 같다. 만약 이 기능이 없었더라면 우리는 더 많은 코딩을 했을것이다.
아래는 좋은 예이다.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Client
{
    delegate int IntOp(int a, int b);

    class Program
    {
        public static int Add(int a, int b) { return a + b; }
        public static int Mul(int a, int b) { return a * b; }

        static void Main(string[] args)
        {
            IntOp[] arOp = {Add, Mul};
            int a=3, b=5;
            int o;

            Console.Write("어떤 연산을 하고 싶습니까?(1:덧셈,2:곱셈)");
            o = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("결과는 {0} 입니다.", arOp[o-1](a,b));
        }
    }
}

아래는 책의 나온 내용 입니다~ ㅎㅎ
좋은 예제 인거 같아서 올려 봅니다. 참고하세요.

"익명메서드는 코드를 정의하기는 하지만 일종의 값으로 분류되므로 델리게이트 객체에 대입할 때 제일 끝의 세미콜론을 빼먹지 않도록 주의해야 한다."

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Server;

namespace Client
{
    delegate int dele(int a, int b);

    class Program
    {
        static void Main(string[] args)
        {
            dele d = delegate(int a, int b) { return a + b; };
            int k = d(2, 3);
            Console.WriteLine(k);
        }
    }
}

'객체지향언어 > C#' 카테고리의 다른 글

listview를 이용해 보자  (0) 2009.08.11
델리게이트 - 참조  (0) 2009.08.10
DllImport 어트리뷰트 사용 예제.  (0) 2009.08.10
배틀넷 아뒤와 방제를 가지고 온다.  (0) 2009.08.09
FileWatcher 예제  (0) 2009.08.09

win32 api 함수중 messagebox를 호출하는 예제 입니다.

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;
using System.Diagnostics;

using System.IO; // 파일 스트림 처리
using Microsoft.Win32; // 레스트리 콘트롤

using System.Runtime.InteropServices; // DllImport 어트리뷰트가 정의됨

namespace OpenFile
{
    public partial class Form1 : Form
    {
       
        [DllImport("User32.dll")] // 윈도우 시스템 파일 User32.dll 참조
        public static extern int MessageBox(int hwnd, string lpText, string lpCaption, int uType);

        public Form1()
        {
            InitializeComponent();
        }
       
        private void Form1_Load(object sender, EventArgs e)
        {
            MessageBox(0, "Win32 MessageBox 호출", "DllImport 사용하기", 3);

        }

    }
}

'객체지향언어 > C#' 카테고리의 다른 글

델리게이트 - 참조  (0) 2009.08.10
델리게이트 - 익명메소드 예제.  (0) 2009.08.10
배틀넷 아뒤와 방제를 가지고 온다.  (0) 2009.08.09
FileWatcher 예제  (0) 2009.08.09
GetFiles 예제  (0) 2009.08.09
레지스트리 공부하면서 심심해서 만들어 보았습니다.


'객체지향언어 > C#' 카테고리의 다른 글

델리게이트 - 익명메소드 예제.  (0) 2009.08.10
DllImport 어트리뷰트 사용 예제.  (0) 2009.08.10
FileWatcher 예제  (0) 2009.08.09
GetFiles 예제  (0) 2009.08.09
이진파일 저장 예제  (0) 2009.08.08

FileSystemWatcher 컴포넌트를 배치해 놓고, Path프로퍼티 : C:\로 설정

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;

using System.IO; // 파일 스트림 처리

namespace OpenFile
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
       
        private void button1_Click(object sender, EventArgs e)
        {
        }

        private void button2_Click(object sender, EventArgs e)
        {
        }

        private void Form1_Load(object sender, EventArgs e)
        {
        }

        private void fileSystemWatcher1_Changed(object sender, FileSystemEventArgs e)
        {
            listBox1.Items.Add("파일이 변경되었습니다.");
        }

        private void fileSystemWatcher1_Created(object sender, FileSystemEventArgs e)
        {
            listBox1.Items.Add("파일이 생성되었습니다.");
        }

        private void fileSystemWatcher1_Deleted(object sender, FileSystemEventArgs e)
        {
            listBox1.Items.Add("파일이 삭제되었습니다.");
        }

        private void fileSystemWatcher1_Renamed(object sender, RenamedEventArgs e)
        {
            listBox1.Items.Add("파일이 이름이 바뀌었습니다.");
        }
    }
}

'객체지향언어 > C#' 카테고리의 다른 글

DllImport 어트리뷰트 사용 예제.  (0) 2009.08.10
배틀넷 아뒤와 방제를 가지고 온다.  (0) 2009.08.09
GetFiles 예제  (0) 2009.08.09
이진파일 저장 예제  (0) 2009.08.08
메모장 흉내내기~  (0) 2009.08.08

GetFiles(시작경로, 검색패턴, 서브까지 할것인)

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;

using System.IO; // 파일 스트림 처리

namespace OpenFile
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
       
        private void button1_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            string[] Files = Directory.GetFiles(Environment.SystemDirectory, "*.bin",
                             SearchOption.TopDirectoryOnly);
            foreach (string Name in Files)
            {
                listBox1.Items.Add(Name);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
        }

        private void Form1_Load(object sender, EventArgs e)
        {
        }
    }
}

'객체지향언어 > C#' 카테고리의 다른 글

배틀넷 아뒤와 방제를 가지고 온다.  (0) 2009.08.09
FileWatcher 예제  (0) 2009.08.09
이진파일 저장 예제  (0) 2009.08.08
메모장 흉내내기~  (0) 2009.08.08
Stream을 이용한 파일 입출력 예제  (0) 2009.08.08

+ Recent posts