//編集コントロールを初期化する //編集コントロールは別のセルや列でも使いまわされるため、初期化の必要がある public override void InitializeEditingControl( int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle) { base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle); //編集コントロールの取得 dgvInventoryControl inventoryBox = this.DataGridView.EditingControl as dgvInventoryControl; if (inventoryBox != null) { //Textを設定 string text = initialFormattedValue as string; inventoryBox.Text = text != null ? text : ""; //カスタム列のプロパティを反映させる dgvInventoryColumn column = this.OwningColumn as dgvInventoryColumn; if (column != null) { inventoryBox.MaxLength = column.MaxInputLength; inventoryBox.UseThousandSeparator = column.UseThousandSeparator; inventoryBox.txt_Type = (dgvInventoryControl.Type)column.TxtType; } } }
//新しいプロパティを追加しているため、 // Cloneメソッドをオーバーライドする必要がある public override object Clone() { dgvInventoryColumn col = (dgvInventoryColumn)base.Clone(); col.maxInputLength = this.maxInputLength; col.UseThousandSeparator = this.usethousandSeparator; col.txtType = this.txtType; return(col); }