Guest User

Untitled

a guest
Sep 17th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. How to display text in DataGridViewComboBoxColumn when the databound value is null
  2. //attach in code or via designer:
  3. dataGridView1.CellFormatting += new DataGridViewCellFormattingEventHandler(dataGridView1_CellFormatting);
  4.  
  5.  
  6. //example implementation:
  7. void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
  8. {
  9. if (e.ColumnIndex == Column1.Index && e.Value==null)//where Column1 is your combobox column
  10. {
  11. e.Value = "Empty";
  12. e.FormattingApplied = true;
  13. }
  14. }
Add Comment
Please, Sign In to add comment