datagridview 数据处理方法 修改 删除 添加 下拉类表 弹出窗口
cmb_Temp.ValueMember ="user_class_id"; //设置隐含的形式显示数值,起对应一定的名称
//cmb_Temp.ValueMember = "user_class";
cmb_Temp.DisplayMember = "user_class";
cmb_Temp.DataSource = dtSex;
cmb_Temp.DropDownStyle =ComboBoxStyle.DropDownList; //只能选择,不能写入 //cmb_Temp.DropDownStyle =ComboBoxStyle.DropDown; //可以写入
// cmb_Temp.DropDownStyle = ComboBoxStyle.Simple;
}
///
// 当用户选择下拉列表框时改变DataGridView单元格的内容
private void cmb_Temp_SelectedIndexChanged(object sender, EventArgs e)
{
if (dataGridView1.CurrentCell != null)
{
DataRowView myrowview = (DataRowView)cmb_Temp.SelectedItem;
//dataGridView1.CurrentCell.Value = cmb_Temp.SelectedValue.ToString(); dataGridView1.CurrentCell.Value = myrowview[2].ToString();//选取的文本 dataGridView1.CurrentCell.Tag = cmb_Temp.SelectedValue; //选取的编码
// MessageBox.Show("text:" + cmb_Temp.SelectedText + "-item:" +
cmb_Temp.SelectedItem.ToString() + "-value:" +
cmb_Temp.SelectedValue.ToString()+"-index:"+cmb_Temp.SelectedIndex.ToString());
// DataRowView myrowview = (DataRowView)cmb_Temp.SelectedItem;
//
MessageBox.Show(myrowview[0].ToString()+"--"+myrowview[1].ToString()+"--"+myrowview[2].ToString()); //获得对应的value和text