chandu gummadi

chandu gummadi

  • NA
  • 67
  • 71.7k

c#.net datagridviewcontrol

Oct 4 2012 2:33 AM
hi friends iam using datagridviewcombobox column in c#.net.
iam using below code
   DataGridViewComboBoxColumn clnStatus = new DataGridViewComboBoxColumn();
   clnStatus.DataPropertyName = "Status";
   clnStatus.Name = "Absent - Leave - Present";
   clnStatus.DataSource = new string[] { "Absent", "Leave", "Present" };
   DgvTeacherAttendance.Columns.Add(clnStatus);
but at runtime combobox column doest show any value it shows empty value.
 for this problem your are sending the below code
 private void DgvTeacherAttendance_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
  if (e.ColumnIndex == 0) //set your index of dropdown here 
{
 e.Value = "Absent";
}
}
but if iam using this code at runtime datagridviewcombobox column shows Absent,Present,Leave it's ok now. but the problem is if iam selecting "present" from combobox
next iam moving to another combobox and select "leave" now the first combobox does't show present it acceptes Absent every time why should i get this problem please help me..