DEV GridControl控件使用(CheckBox全選、操作按鈕、事件處理,獲取值)


1、GridControl控件使用

(1)綁定數據源

//綁定DataTable
gridControl1.DataSource = DbHelper.ExecuteDataTable("SELECT * FROM dc_Log");

(2)配置顯示列

(3)插入按鈕列

(4)插入復選框CheckBox

(5)獲取操作按鈕列的值

設置按鈕事件

獲取當前行的值

    private void repositoryItemButtonEdit1_Click(object sender, EventArgs e)
    {
        //獲取點擊行的索引
        int RowIndex = gridView1.GetFocusedDataSourceRowIndex();

        //輸出值
        MessageBox.Show(gridView1.GetRowCellValue(RowIndex, "LogId").ToString());
    }

(6)獲取CheckBox的值

設置批量操作按鈕

按鈕點擊事件

    private void simpleButton1_Click(object sender, EventArgs e)
    {
        //獲取所選擇的行
        int[] rows = gridView1.GetSelectedRows();

        foreach(int i in rows)
        {
            //輸出值
            MessageBox.Show(gridView1.GetRowCellValue(i, "LogId").ToString());
        }
    }

(7)設置Dock屬性


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM