回复 4楼 zhoufeng1988
创建ComboBox控件(名为combText,;DataGridView控件名:dgvForecastData
1、combText并添加内容
for(int i=1;i++;i<50)
{
combText.Items.Add(i);
}
2、单击dgvForecastData第二列则显示combText中的内容1-50
private void dgvForecastData_CurrentCellChanged(object sender, EventArgs e)
{
try
{
if (dgvForecastData.CurrentCell.ColumnIndex ==2 )
{
Rectangle rect = dgvForecastData.GetCellDisplayRectangle ( dgvForecastData.CurrentCell.ColumnIndex, dgvForecastData.CurrentCell.RowIndex, false);
string sexValue = dgvForecastData.CurrentCell.Value.ToString();
combText.Left = rect.Left;
combText.Top = rect.Top;
combText.Width = rect.Width;
combText.Height = rect.Height;
combText.Visible = true;
}
else
{
combText.Visible = false;
}
}