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
374
swapping columns programmatically
posted

Hi all,

I have a grid that I'm binding to a datatable.   I create several unbound columns in the initialize layout event but I'm not sure how to move these or change the order in which they are displayed.

I want to move them when the grid is bound, then lock the grid down by setting ugmain.DisplayLayout.Override.AllowColSwapping = Infragistics.Win.UltraWinGrid.AllowColSwapping.NotAllowed

Parents
  • 469350
    Verified Answer
    Offline posted

     Hi Brian,

        Column swapping is not allowed by default, so the line of code you hae here is probably unneccessary.

        To position a column in code, you need to position the header. So I would use the InitializeLayout event of the grid and do something like this:

    e.Layout.Bands[0].Columns["Column I want first"].Header.VisiblePosition = 0; 

    e.Layout.Bands[0].Columns["Column I want second"].Header.VisiblePosition = 1;

    e.Layout.Bands[0].Columns["Column I want third"].Header.VisiblePosition = 2;

        Note that you must assign the visible positions in order. Otherwise, setting the position of one column might alter the positions of columns to the right of it.

        You may also want to set AllowColMoving to prevent the users from dragging the columns around. 

Reply Children
No Data