简体   繁体   中英

DataGridViewComboBox value is not valid linq

Im filling my datagridview comboxcolumn with this code:

 (dgvHopDong.Columns["MaNCC"] as DataGridViewComboBoxColumn).DataSource = QL.NhaCungCaps.Select(n => new { MaNCC = n.MaNCC, TenNCC = n.TenNCC }).ToList();            
            (dgvHopDong.Columns["MaNCC"] as DataGridViewComboBoxColumn).DisplayMember = "TenNCC";
            (dgvHopDong.Columns["MaNCC"] as DataGridViewComboBoxColumn).ValueMember = "MaNCC";

and the error is:

DataGridViewComboBoxCell value is not valid?

and i dont know why. thank you so much!

值类型缺失。

(dgvHopDong.Columns["MaNCC"] as DataGridViewComboBoxColumn).ValueType = typeof(string);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM