dataGridView1.Columns.Clear(); dataGridView1.AutoGenerateColumns = false; dataGridView1.DataSource = dt; DataGridViewComboBoxColumn comUserName= new DataGridViewComboBoxColumn(); comUserName.DataPropertyName = "userName";//**设置数据源属性的名称 comUserName.HeaderText = "用户名";//列头显示的汉字 comUserName.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox; comUserName.DataSource = dtAll;//下拉框绑定的数据源 comUserName.DisplayMember = "userName_chinese";//下拉框显示内容 comUserName.ValueMember = "userName";//要和上面**处的一样 dataGridView1.Columns.Add(comUserName);
时间: 2024-10-07 22:37:21