0
votes

I have this code :

private void frmWeld_Load(object sender, EventArgs e)
{
    List<Weld> lst = _weldRepository.Get().ToList();
    gridControl.DataSource = new BindingList<Weld>(lst) { AllowNew = true };
}

I want to load my data into devExpressGridView

enter image description here

As you can see my data is loaded but the gridview can't show the data and my break point doesn't pass from gridControl.DataSource = new BindingList<Weld>(lst) { AllowNew = true} and my program remains with this state. Why?

I just add new column to my gridview after this the problems occurreded. I use entity framework ,when i change the database my application creates a new database using code first and after that my data is lost but the problem that i said is solved.

1
if you just assign lst directly to the data source, what would happen? - woodykiddy
@woodykiddy same error - Mehrdad Ghaffari
What is the error if you debug? - Marko Juvančič
I said no error happens just the gridview doesn't show ant data ,something like stopped - Mehrdad Ghaffari
Do you see rows with blank cells, or no rows at all? - Brendon

1 Answers

0
votes

Since your code is executing in Load event, add ForceInitialize() to your code.

private void frmWeld_Load(object sender, EventArgs e) 
{
  // your previous code
  gridControl.ForceInitialize(); <- add this line
}