I use Visual Studio 2005 and create a simple Windows application.
I created a DataGridView with 2 textbox columns. Databinding is OK, but I cannot edit any cell (no matter I press F2, or click the cell). I only see the cell is highlighted with blue backgound color.
This is my code for binding data to DataGridView:
privatevoid BindData(KeyValueConfigurationCollection keyValueCollection)
{
DataTable myDataTable = CreateTableForGridView();DataRow myDataRow;
foreach (KeyValueConfigurationElement keyValue in keyValueCollection)
{
if (!keyValue.Key.Equals("lookupCategoryForCheckin") && !keyValue.Key.Equals("useOriginialPrintData"))
{
"PrinterIP"] = keyValue.Key;myDataRow = myDataTable.NewRow();
myDataRow[
myDataRow[
"PrinterName"] = keyValue.Value;myDataTable.Rows.Add(myDataRow);
}
}
// Binds the data to GridView ControlDataView dtView = newDataView();try{
BindingSource bs = newBindingSource();
bs.DataSource = myDataTable;
dgvPrinter.DataSource = bs;
dgvPrinter.EditMode =
DataGridViewEditMode.EditOnEnter;}
catch (Exception ex) { }}
If I don't bind code, then I can see a blank datagridview, and I can edit.
Please help.... and many thanks!!!