내 DataGrid보기에서 드롭 다운 콤보 상자의 편집 컨트롤이 떠오르고 사용자가 너비를 확장하면 보조 콤보 상자가 나타납니다.DataGridView : 신비한 두 번째 드롭 다운
이것은 내가 false로 그 설정이 있기 때문에 AutoGeneratedColumns에 의해 발생하는 경우가 없습니다.
protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e)
{
base.OnCellPainting(e);
if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
{
DataGridViewRow currentRow = this.Rows[e.RowIndex];
DataGridViewCell currentCell = currentRow.Cells[e.ColumnIndex];
DataItem item = currentRow.DataBoundItem as DataItem;
if (item != null)
{
if (new string[] { "Property1", "Property2" }.Contains(this.Columns[e.ColumnIndex].DataPropertyName))
{
EnableDisableCell(currentCell, item);
}
}
}
}
private void EnableDisableCell(DataGridViewCell cell, DataItem boundItem)
{
if (cell != null)
{
switch (cell.OwningColumn.DataPropertyName)
{
case "Property1":
if (boundItem.AllowP1Assignment)
{
cell.Enable();
}
else
{
cell.Disable();
}
break;
case "Property2":
if (boundItem.AllowP2Assignment)
{
cell.Enable();
}
else
{
cell.Disable();
}
break;
default:
break;
}
}
}
편집 :
EnableDisableCell() 메소드는 범인 될 것 같지 않습니다. 나는 그것을 주석 처리했고 동일한 유물을 보았다.
은 그냥 페인트 오류입니까? 아니면 둘 다 작동합니까? – TaW
@Taw : 드롭 다운이 항상 왼쪽 수직 열의 행에 대해 (항상 오른쪽 콤보 상자로 플러시되지 않으므로) 페인트 오류로 나타납니다. 또한 OnPaint 호출에는 항상 this.GetHashCode() 값이 동일합니다. 또한 너비는 OnPaint 호출마다 다릅니다. – micahhoover
아마 DGV 또는 셀 영역을 무효화하면 사라질 것입니다 ..? Paint 이벤트에서 셀의 활성화 된 상태를 변경하면 확실하게 의심 스럽습니다. 이것은 어떤 그림보다 먼저 일어 났어야했다. – TaW