开发者

cannot edit any value in this datagridview

开发者 https://www.devze.com 2023-01-20 10:47 出处:网络
i have a datagridview bould on a list from Mongodb. however i cannot edit the grid. I dunno why its like that?

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

精彩评论

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

关注公众号