We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Left Justify

Thread ID:

Created:

Updated:

Platform:

Replies:

75791 Aug 9,2008 05:43 PM UTC Aug 9,2008 09:12 PM UTC WPF 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On August 9, 2008 05:43 PM UTC

I am interested in trying to left justify a grid control. (All cells in the grid are automatically left justified). I know that I could do this by embedding a flowdocument (and using xaml). I also know that I might use a "datatemplate cell". However, I was hoping for an easier solution. Specifically, I want to do this (copied from the windows forms grid support)

this.gridControl1.TableStyle.HorizontalAlignment=GridHorizontalAlignment.Left;




Administrator [Syncfusion]
Replied On August 9, 2008 08:48 PM UTC

New alignment and font properties have been added to the GridStyleInfo class. These changes are not in the 6.3.0.34 development build that is currently available. But they should be in the next development build that should be on our website this coming week. At that point, the code you showed for our WindowsForms grid should also work for our WPF grid.


Administrator [Syncfusion]
Replied On August 9, 2008 09:10 PM UTC

For those wanting to know a solution to this problem, let me tell you the long (but very flexible way) of doing this. Use a datatemplate. Here are the steps:
(1) Open Syncfusion's DataTemplate_2008 example for WPF grids
(2) Copy the entire class DataTemplateCellRenderer into your project.
(3) Create a in a resource dictionary or in the resource markup in your xaml page. Here is mine:


Padding="0" Margin="0" Width="100" />


(4) In your code behind, add this code in order to apply the template to your cells:

//Make cells left justified
Model.CellModels.Add("DataTemplate", new DataTemplateCellModel());
Model.QueryCellInfo += new Syncfusion.Windows.Controls.Grid.GridQueryCellInfoEventHandler(Model_LeftJustify);

(5) Finally add the event that will apply this template:
void Model_LeftJustify(object sender, Syncfusion.Windows.Controls.Grid.GridQueryCellInfoEventArgs e)
{
if (e.Cell.RowIndex > 0 && e.Cell.ColumnIndex > 0)
{
e.Style.CellType = "DataTemplate";
e.Style.CellTemplateKey = "LeftJustify";
}
}

This of course can be very flexible. You can use that data template to put whatever default item that you wish to display.




Administrator [Syncfusion]
Replied On August 9, 2008 09:12 PM UTC



>New alignment and font properties have been added to the GridStyleInfo class. These changes are not in the 6.3.0.34 development build that is currently available. But they should be in the next development build that should be on our website this coming week. At that point, the code you showed for our WindowsForms grid should also work for our WPF grid.



Thanks, Clay, for answering on your Saturday.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;