The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I need to implement a horizontal alignment similar to excel''s "center across selection" alignment. I know the grid only provides near, center, and far horizontal alignments by default. Is there a way, through code, to replicate this alignment as in excel?
Thanks.
ADAdministrator Syncfusion Team April 24, 2006 08:17 AM UTC
Hi Alex,
Please try this code to center the text across the group of cells.Here is a code snippet.
//Form''s Load Event
this.contextMenu1.MenuItems.Add("Center cross Aignment");
this.contextMenu1.MenuItems[0].Click +=new EventHandler(menu1_Click);
private void menu1_Click(object sender, EventArgs e)
{
foreach(GridRangeInfo range in this.gridControl1.Model.SelectedRanges)
{
this.gridControl1.CoveredRanges.Add(range);
this.gridControl1.Model[range.Top,range.Left].HorizontalAlignment = GridHorizontalAlignment.Center;
}
}
Here is a sample.
http://www.syncfusion.com/Support/user/uploads/centerAcrossSelection_faa923ef.zip
Please let me know if you need any further assistance.
Regards,
Haneef