以下是在网上看到的网友发的文章“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;
}
}
选项,而自己输入的问题。




本文介绍了一种在DataGridView控件中实现下拉框的方法,通过简单的编程即可在指定列显示下拉框,同时保持界面整洁美观。该方法适用于VS2005 C#应用程序。
7627

被折叠的 条评论
为什么被折叠?



