[SOLVED] Widget is not focusable

Answered
0
0

Hi

I am getting this error on attempting cell edit. (See attached)

Any ideas how to fix?

This is the code I am using which works fine when loading the data into the grid

using System;
using System.Collections.Generic;
using System.Data;
using Wisej.Web;

namespace wjServiceDirectory
{
public class DataGridViewMultiComboBoxColumn : DataGridViewComboBoxColumn
{
public DataGridViewMultiComboBoxColumn() : base()
{
this.Editor = new DataGridViewMccbEditor();
}
}

public class DataGridViewMultiComboBoxColumnCell : DataGridViewComboBoxCell
{

public DataGridViewMultiComboBoxColumnCell()
{
Control = new MultiColumnComboBox()
{
//DropDownRows = 16,
//ColumnVisible = new List { true, true, true, true, true, false },
//ColumnWidths = new List { 80, 250, 250, 200, 80, 0 },
//KeyColumn = 0,
//DisplayColumn = 1,
//Border = BorderStyle.None,
Dock = DockStyle.Fill,
};
//this.Style.ForeColor = System.Drawing.Color.Transparent;
}

public void MultiCombo_SelectionMade(object sender, EventArgs e)
{
Value = ((MultiColumnComboBox)sender).BoundValue;
}

public override Type FormattedValueType
{
get { return typeof(string); }
}

public override Type ValueType
{
get { return typeof(string); }
set { }
}

protected override bool SetValue(object value)
{
((MultiColumnComboBox)this.Control).BoundValue = value;

return base.SetValue(value);
}
}

public class DataGridViewMccbEditor : MultiColumnComboBox, IDataGridViewEditingControl
{
public DataGridView DataGridView { get; set; }

public bool Invalid
{
get { return false; }
}

public void ApplyCellStyleToEditingControl(DataGridViewCellStyle style)
{
}

public string GetEditingControlFormattedValue()
{
return this.BoundValue.ToString();
}

public void PrepareEditingControlForEdit(bool selectAll)
{
DataGridViewMultiComboBoxColumn cmb = this.DataGridView.CurrentCell.OwningColumn as DataGridViewMultiComboBoxColumn;
DataTable dtMcc = ((DataTable)cmb.DataSource).Copy();
DropDownRows = 16;
ColumnVisible = new List { true, true, true, true, true, false };
ColumnWidths = new List { 80, 250, 250, 200, 80, 0 };
KeyColumn = 0;
DisplayColumn = 1;
Border = BorderStyle.None;
Dock = DockStyle.Fill;
refreshMCC(dtMcc);
this.BoundValue = this.DataGridView.CurrentCell.Value;
}
}

Thanks for your help Ewan

Attachment
  • You must to post comments
Good Answer
0
0

It expects an editable control. The code is using a panel.

  • Ewan Walker
    Could you let me have the code for the DataGridViewComboBoxColumn as I would effectively need to extend this in my case as simply attempting to inherit it will not do.
  • Luca (ITG)
    It won’t compile, it uses internal implementations. What do you need to do?
  • Ewan Walker
    Hi Luca Its about producing the Value Member / Display Member in the DGV the same way the Combo Box Column implements it, so that the Filter extension picks up the Display Member
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.