Initialize Layout not working after update

I am calling IntializeLayout on my EpiUltraGrid to customize the grid headers, order and width. This worked fine in version 10.1.500, after upgrading to 10.2.300 this no longer works. Debugging in Visual Studio, I see the code does get called, but it either doesn’t take or is overridden by the default layout. Any ideas?

	private void UGChangeLog_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs args)
{
	// ** Place Event Handling Code Here **
	Infragistics.Win.UltraWinGrid.UltraGridLayout layout = args.Layout;
	Infragistics.Win.UltraWinGrid.UltraGridBand band = layout.Bands[0];
   
	band.Columns["Date01"].Header.Caption = "Change Date";
	band.Columns["Number01"].Header.Caption = "Amount";
	band.Columns["Number02"].Header.Caption = "Line #";
	band.Columns["Character01"].Header.Caption = "Description";
	band.Columns["Character10"].Header.Caption = "Changed By";
	
	band.Columns["Number01"].Format = "#,##0";
	band.Columns["Number02"].Format = "#,##0";

	band.Columns["Date01"].Width = 90;
	band.Columns["Number01"].Width =120;
	band.Columns["Number02"].Width = 40;
	band.Columns["Character01"].Width = 300;
	band.Columns["Character10"].Width = 120;

	band.Columns["Date01"].Header.VisiblePosition = 1;
	band.Columns["Number01"].Header.VisiblePosition = 2;
	band.Columns["Number02"].Header.VisiblePosition = 3;
	band.Columns["Character01"].Header.VisiblePosition = 4;
	band.Columns["Character10"].Header.VisiblePosition = 5;

	band.Columns["Number01"].CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right;
	band.Columns["Number02"].CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right;
	
}

I see you have some Visual Studio Skills… I don’t have an answer to your question.

For the sake of the Beginners who will use your code and consider it “best practice” while it probably isn’t the best approach. Why are you changing Titles, Positions and Widths in Code? Just curious.

Was there an issue with using the Customization Editor and Save Grid Layouts? :sunglasses: In addition using Extended Properties which will change the Titles/Visibility for you…

Why? At the time I was still learning and finding my way around the Epicor Customization Tools and still learning. Some things I did not know how to do through the interface and just did it through code.

1 Like

I don’t have a version at hand to test but maybe this helps

// turn it off
myGrid.BeginUpdate();
myGrid.SuspendRowSynchronization();
// do stuff to your rows here
//turn it back on
myGrid.ResumeRowSynchronization();
myGrid.EndUpdate();

SuspendRowSynchronization and ResumeRowSynchronization methods can be used to temporarily suspend UltraGrid from responding to data source change notifications. When row syncrhonization is suspended, the UltraGrid will still mark the rows dirty so it will re-create the rows next time it gets painted.

EndUpdate Resets the Infragistics.Win.UltraControlBase.IsUpdating flag to false and optionally invalidates the control. You can pass a boolean to it.

Perhaps calling
myGrid.EndUpdate(true); forces it to repaint. Assuming that Epicor somewhere decided to set .BeginUpdate();

Try

myGrid.EndUpdate(true); // at the end, the true forces it to repaint