카테고리 보관물: Programming

dataGridView 속성 리스트

 
//컬럼초기화
            this.dataGridView1.Columns.Clear();
 
//컬럼 명 변경
            this.dataGridView1.Columns.Add("gubun", "구분");
            this.dataGridView1.Columns.Add("monthly", month);
//컬럼 숨기기         
            this.dataGridView1.Columns.Add("devi_name", "비고");
            this.dataGridView1.Columns["devi_name"].Visible = false;
//컬럼 고정
            this.dataGridView1.Columns[5].Frozen = true;
            this.dataGridView1.Columns[5].DividerWidth = 2;
//컬럼 싸이즈
            this.dataGridView1.Columns[0].Width = 170;
            this.dataGridView1.Columns[1].Width = 90;
//컬럼 색상
            this.dataGridView1.Columns[13].DefaultCellStyle.BackColor = Color.Cornsilk;
//Sort  금지
            int i;
            for (i = 0; i <= 19; i++)
            {
                this.dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
 
            }
// DB Binding  컬럼 지정
            foreach (DataRow r in dt.Rows)
            {
 
                int n = dataGridView1.Rows.Add();
                dataGridView1.Rows[n].Cells[0].Value = r["devi_cd"].ToString();
                dataGridView1.Rows[n].Cells[1].Value = r["devi_name"].ToString();
                dataGridView1.Rows[n].Cells[2].Value = r["gubun"].ToString();
             }
// DB Binding  DataTable
                DataTable dt = db.GetDBTable(sql);
                dataGridView1.DataSource = dt;
                dataGridView1.Columns[3].Frozen = true;
                dataGridView1.Columns[3].DividerWidth = 2;
 
// Datagridview Row 색상 변경
            private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
            {
               //TOTAL
                if (dataGridView1.Rows[e.RowIndex].Cells["devi_name"].Value.ToString() ==
                        "A" && dataGridView1.Rows[e.RowIndex+3].Cells["gubun"].Value.ToString() == "LIPAS")
                 {
                     dataGridView1.Rows[e.RowIndex+3].DefaultCellStyle.BackColor = Color.FromArgb(255, 196, 255);
                 }
 
                if (dataGridView1.Rows[e.RowIndex].Cells["devi_name"].Value.ToString() == "A" 
                         && dataGridView1.Rows[e.RowIndex+4].Cells["gubun"].Value.ToString() == "VOLPAS")
                 {
               // 전체 폰트
                     dataGridView1.Rows[e.RowIndex+4].DefaultCellStyle.BackColor = Color.FromArgb(255, 232, 255);
                 }
             }

C# sendkey.send 명령어

필요시  키 전송값을 날려야 할때에…

 

SendKeys.Send(“{ENTER}”);  항목으로 날림..

 

 

아래 리스트는 키값들

BACKSPACE –> {BACKSPACE}, {BS}{BKSP}
BREAK –> {BREAK}
CAPS LOCK –> {CAPSLOCK}
DEL OR DELETE –> {DELTE}
DOWN ARROW –> {DOWN}
END –> {END}
ENTER –> {ENTER} OR ~
ESC –> {ESC}
HELP –> {HELP}
HOME –> {HOME}
INS OR INSERT –> {INSRT} OR {INS}
LEFT ARROW –> {LEFT}
NUB LOCK –> {NUMLOCK}
PAGE DOWN –> {PGDN}
PAGE UP –> {PGUP}
PRINT SCREEN –> {PRTSC}
RIGHT ARROW –> {GIGHT}
SCROLL LOCK –> {SCROLLOCK}
TAB –> {TAB}
UP ARROW –> {UP}
F1 –> {F1}
F2 –> {F2}