Click here to Skip to main content
15,878,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using a normal Datagridview but I have a problem with it.
This way I am filling data in my grid and adding combobox column to it

C#
db.DataEntities ss = new db.DataEntities();
  DataGridview1.DataSource = ss.table1.ToList();

  if (!DataGridview1.Columns.Contains("dgcolUser"))
  {
      DataGridViewComboBoxColumn dgcombocolUser = new DataGridViewComboBoxColumn();
      dgcombocolUser.Name = "dgcolUser";

      var listOfAllUsers = ss.secAccountInformations.ToList();
      dgcombocolUser.DataSource = listOfAllUsers;
      dgcombocolUser.DisplayMember = "AccountName";
      dgcombocolUser.ValueMember = "UserId";
      DataGridview1.Columns.Add(dgcombocolUser);
  }

  foreach ( DataGridViewRow dgr in DataGridview1.Rows)
  {
      dgr.Cells["dgcolUser"].Value = dgr.Cells["PermittedUserId"].Value;
  }


I am opening this Form in a MDI parent
C#
Form1 frm = new Form1() { MdiParent = MdiForm1};
frm.Show();

when I open my form it not displaying any selected value in Comboboxcolumn
But when I open my Form frm1 not it MdiParent it display selected value in Comboboxcolumn

C#
Form1 frm = new Form1();
frm.Show();

so is this really happen because it shows data when i am showing my form without MdiParnet or is there any other reason due to which it is not happening<br>
Please give me better suggesstion.. because showing form without MdiParent is not valid solution.
Posted
Updated 23-Aug-16 4:51am
v3
Comments
Rahul_Pandit 25-Nov-13 1:25am    
what is selected in combox in mdiparent..use selected value property to select value of combox

1 solution

I had the same problem. I believe you are populating the DGV on form Load event. If you move that code to Form Activivate then this should work within MDI form
 
Share this answer
 
Comments
Asavani Anil 22-Oct-19 7:22am    
Thanks bro it solve my problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900