Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Cells in DataGridView cannot edit

$
0
0

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"))

{

myDataRow = myDataTable.NewRow();

myDataRow[

"PrinterIP"] = keyValue.Key;

myDataRow[

"PrinterName"] = keyValue.Value;

myDataTable.Rows.Add(myDataRow);

}

}

// Binds the data to GridView Control

DataView 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!!!

 

Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>