데이터테이블DataTable 만들기

public void TableSetting(ref DataTable table, ref string[] 항목명, ref string[] 데이터타입)
        {
            DataColumn column;

            for (int i = 0; i < 항목명.Length; i++)
            {
                column = new DataColumn();
                column.DataType = System.Type.GetType(데이터타입[i]);
                //DataNames = i;
                //column.ColumnName = Convert.ToString(DataNames);
                column.ColumnName = 항목명[i];
                column.ReadOnly = true;
                column.Unique = false;
                // Add the Column to the DataColumnCollection.
                table.Columns.Add(column);
            }
        }

데이터 테이블 만들기

구조체를 이용할 수 있다면 더할나위없겠지만…

구조체는 아무리 찾아봐도 방법이 없다

문자열 배열이나

열거형을 사용하는게 좋겠다

타입배열도 가능하지만… 문자열이나 타입이나 뭐…

 

enum 친구들
{ 철수, 멍멍이, 개똥이, 똥깨}
Enum.GetNames(typeof(친구들))[i]

에넘을 쓸때는 이렇게 하면 배열처럼 사용 가능하다.

 

DataGridView dgv1;

dgv1.Clear; //청소 먼저… 이게 맞나… 뭐 이거 아니라도 clear remove 등등 찾아보면 금방 나온다.

dgv1.DataSource = 데이터테이블;

이렇게 하면… 데이터 그리드 뷰에 자동입력된다. 편하다.

Leave a Reply

Your email address will not be published. Required fields are marked *

 characters available