开发者

cannot edit any value in this datagridview

i have a datagridview bould on a list from Mongodb. however i cannot edit the grid. I dunno why its like that?

var connstr = "Server=localhost:27017";
mongo = new Mongo(connstr);
mongo.Connect();

IMongoDatabase TorontoTrader = mongo["TorontoTrader"];
IMongoCollection TradingStrategyCollection = TorontoTrader["TradingStrategyRefresher"];
IEnumerable<Document> docs =
   from doc in TradingStrategyCollection.Linq()
   where (int)doc["TriggerBarId"] == 102
   select doc;

dataGri开发者_运维百科dView1.ReadOnly = false;
dataGridView1.DataSource = docs.First().ToList();


I guess you must set the ItemsSource of your datagridview to an observableCollection instance.

dataGridView1.DataSource = new ObservableCollection<Document>(docs.First());

This probably will make the grid editable, but it will not save back the edits to the database.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜