ComboBox
で使用したいカスタムコントロールがありDataGridViewCell
ます。私は最初に継承し、セルにペイントするメソッドをDataGridViewCell
オーバーライドしようとしています。Paint()
ComboBox
私の問題は、プロパティを継承してクラスの新しいインスタンスにDataGridViewColumn
設定した後、セルが灰色で内容がないことです。CellTemplate
CustomDataGridViewCell
クラス変数は、cBox
オブジェクトctorでインスタンス化されます。
protected override void Paint(Graphics graphics, Rectangle clipBounds,
Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState,
object value, object formattedValue, string errorText,
DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle borderStyle,
DataGridViewPaintParts paintParts)
{
// Call MyBase.Paint() without passing object for formattedValue param
base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value,
"", errorText, cellStyle, borderStyle, paintParts);
// Set ComboBox properties
this.cBox.CheckOnClick = true;
this.cBox.DrawMode = System.Windows.Forms.DrawMode.Normal;
this.cBox.DropDownHeight = 1;
this.cBox.IntegralHeight = false;
this.cBox.Location = new System.Drawing.Point(cellBounds.X, cellBounds.Y);
this.cBox.Size = new System.Drawing.Size(cellBounds.Width, cellBounds.Height);
this.cBox.ValueSeparator = ", ";
this.cBox.Visible = true;
this.cBox.Show();
}
ComboBox
セル内を正しくペイントするにはどうすればよいですか?