獲取表格記錄ID值

獲取表格記錄ID值ide

 

 

  private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            //獲取行首的單元格雙擊事件,並以此值做爲傳參對象this

            //get id column index
           int IdcolumeIndex=0;
            foreach (DataGridViewTextBoxColumn item in this.dataGridView1.Columns)
            {
                if(item.Name.Equals("id"))
                {
                  IdcolumeIndex=  item.Index;
                }對象

            }事件

            object objCellValue = this.dataGridView1.Rows[e.RowIndex].Cells[IdcolumeIndex].Value;
         
            string s= objCellValue.ToString().Trim();
            MessageBox.Show(s);
            addrecord ar =                        new addrecord();
            ar.editid = Convert.ToInt32(s);
            ar.Show();
        }get

相關文章
相關標籤/搜索