Faking alternative controls within a DataGridView control in Win Forms 2.0을보고 싶습니다. 처럼 컨트롤이 DataGridView 내에서 호스팅되는 것처럼 보이지만 실제로는 셀 위에 잘 배치됩니다. 큰 DateTimePickers와 하나의 ComboBox에서이 기능을 사용하고 있습니다. 링크에서
샘플 코드 :
protected void dgCategory_CellClick(object sender, DataGridViewCellEventArgs e)
{
//set Date Picker to false when initially click on cell
if (dtPicker.Visible)
dtPicker.Visible = false;
if (e.ColumnIndex == 2)
{
//set date picker for category datagrid
dtPicker.Size = dgCategory.CurrentCell.Size;
dtPicker.Top = dgCategory.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).Top;
dtPicker.Left = dgCategory.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).Left;
if (!(object.Equals(Convert.ToString(dgCategory.CurrentCell.Value), "")))
dtPicker.Value = Convert.ToDateTime(dgCategory.CurrentCell.Value);
dtPicker.Visible = true;
}
}
private void dtPicker_ValueChanged(object sender, EventArgs e)
{
dgCategory.CurrentCell.Value = dtPicker.Value;
dtPicker.Visible = false;
}
아니, 그것은 자신의 문제를 해결하는 데 도움이되지 않습니다. – SLaks