I am trying to set a DataGridViewTextBoxCell.Value in formLoad, which kind of works, I can set it, but nothing is displayed.
DataGridViewTextBoxCell cel = (DataGridViewTextBoxCell)gvAirSegment.Rows[rowNumber].Cells[0];
cel.Value = "TEST";
This works, on button click, but does not work when its within a Form_Load. I have tr开发者_如何转开发ied Refresh(), RefreshEdit(), InvalidateCell nothing seems to work, my guess is that its not fully created yet? even though I am doing this after I add all my items to the gridview... any help?
A DGV will not go into edit mode until it is visible. OnLoad is too soon, the form isn't visible yet. You could use the OnShown() method instead, it runs right after the form and all controls are painted for the 1st time. Or you could just directly assign the cell, no need to jump through the DataGridViewTextBoxCell hoop.
精彩评论