Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
335
Right align String column in code-behind...newbie question...
posted

I have to right-align several columns thru code-behind in vb.  How can I specify which columns to align and how can I do this? I have been using the fieldlayout settings class, but I think I am missing something.

Thanks

 

 

  • 395
    Suggested Answer
    posted

    I have similar code in C# but to center a column value (in code-behind). For a right-alignement I think I could just change the HorizonalAlignment to .Right instead of .Center. Here is a snippet of the code I'm using:

    In event for FieldLayoutInitialized -

    ...

     

     

    Style centerColumnStyle = new Style(typeof(CellValuePresenter));

    centerColumnStyle.Setters.Add(new Setter(CellValuePresenter.HorizontalAlignmentProperty, HorizontalAlignment.Center));

    ...

    Field

     

     someColumn = new Field();

    someColumn.Settings.CellValuePresenterStyle = centerColumnStyle;

    ...

    e.FieldLayout.Fields.Add(someColumn);

     

    Not sure on the VB equivalent but maybe you can convert this readily enough?