以下是在网上看到的网友发的文章“VC++.NET2005中DataGridView控件中加入下拉框的编程实现”用C#作了
修改的后的方法如下:
如图:
private void Form1_Load(object sender, EventArgs e)
{
this.cobgv.Visible = false;
this.cobgv.Width = 0;
}
else
{
if (this.dgvStu.CurrentCell.ColumnIndex == 2)//下拉框所放置的列
{
this.cobgv.Visible = false;
this.cobgv.Width = 0;
this.cobgv.Left = this.dgvStu.GetCellDisplayRectangle(this.dgvStu.CurrentCell.ColumnIndex, this.dgvStu.CurrentCell.RowIndex, true).Left;
this.cobgv.Top = this.dgvStu.GetCellDisplayRectangle(this.dgvStu.CurrentCell.ColumnIndex, this.dgvStu.CurrentCell.RowIndex, true).Top;
this.cobgv.Width = this.dgvStu.GetCellDisplayRectangle(this.dgvStu.CurrentCell.ColumnIndex, this.dgvStu.CurrentCell.RowIndex, true).Width;
string ffff = Convert.ToString(this.dgvStu.CurrentCell.Value);
this.cobgv.Text = ffff;
this.cobgv.Visible = true;
}
else
{
this.cobgv.Visible = false;
this.cobgv.Width = 0;
}
}
选项,而自己输入的问题。