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
235
MaxWidth ignored
posted

This is similar to Problem with column width after setting hierarchical binding list and Column.Width overwritten and MaxWidth ignored posts; however, my issue seem to have a little different approach.

I am binding the data in the Form_Load event, and trying to set max width for certain columns in the UltraGrid_InitializeLayout event. The MaxWidth is not being honored in this case and I am not sure why. Can someone please help shed some light on this?

private void ugResourcePlanning_InitializeLayout(object sender, InitializeLayoutEventArgs e)
{
    try
    {
        Infragistics.Win.BindableValueList bvl;
        string column;
        int parent = sd._parentBand;
        int headerPos = 0;
        
        // Default setup
        sf.ugDefaultSetup(e, true, true, Activation.AllowEdit);
        // Adds an empty row to add a new entry
        e.Layout.Override.AllowAddNew = AllowAddNew.TemplateOnBottom;
        e.Layout.AutoFitStyle = AutoFitStyle.None;
       
        // Define columns.
        //// ID
        //// ***HIDDEN***
        column = sd._fldResourceManagementID;
        e.Layout.Bands[parent].Columns[column].Hidden = true;
                
        //// Project
        //// Caption: "Project"
        column = sd._fldResourceManagementProject;
        bvl = new Infragistics.Win.BindableValueList(Prototype.ddlGetProject(), "", "Value", "ID", ugResourcePlanning);
        //bvl.SelectedIndex = 0;
        e.Layout.Bands[parent].Columns[column].Header.Caption = "Project";
        e.Layout.Bands[parent].Columns[column].Header.VisiblePosition = headerPos++;
        e.Layout.Bands[parent].Columns[column].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
        e.Layout.Bands[parent].Columns[column].Width = 130;
        e.Layout.Bands[parent].Columns[column].ValueList = bvl;
        
        
        //// Resource
        //// Caption: "Resource"
        column = sd._fldResourceManagementResource;
        bvl = new Infragistics.Win.BindableValueList(Prototype.ddlGetResource(), "", "Value", "ID", ugResourcePlanning);
        e.Layout.Bands[parent].Columns[column].Header.Caption = "Resource";
        e.Layout.Bands[parent].Columns[column].Header.VisiblePosition = headerPos++;
        e.Layout.Bands[parent].Columns[column].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
        e.Layout.Bands[parent].Columns[column].MinWidth = e.Layout.Bands[parent].Columns[column].MaxWidth = 100;
        e.Layout.Bands[parent].Columns[column].ValueList = bvl;

        //// Group
        //// Caption: "Group"
        column = sd._fldResourceManagementGroup;
        bvl = new Infragistics.Win.BindableValueList(Prototype.ddlGetGroup(), "", "Value", "ID", ugResourcePlanning);
        e.Layout.Bands[parent].Columns[column].Header.Caption = "Group";
        e.Layout.Bands[parent].Columns[column].Header.VisiblePosition = headerPos++;
        e.Layout.Bands[parent].Columns[column].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
        e.Layout.Bands[parent].Columns[column].MinWidth = e.Layout.Bands[parent].Columns[column].MaxWidth = 80;
        e.Layout.Bands[parent].Columns[column].ValueList = bvl;
        
        //// Month 1 Planned
        //// Caption: {Set by function}
        column = sd._fldResourceManagementPlanned1;
        e.Layout.Bands[parent].Columns[column].Header.Caption = "Planned";
        e.Layout.Bands[parent].Columns[column].Header.VisiblePosition = headerPos++;
        e.Layout.Bands[parent].Columns[column].CellActivation =
        (_employee.IsAdministrator || _employee.IsClientRelationsManager)
        ? Activation.AllowEdit
        : Activation.NoEdit;
        e.Layout.Bands[parent].Columns[column].Format = "##%";
        e.Layout.Bands[parent].Columns[column].MaxWidth = 50;
        e.Layout.Bands[parent].Columns[column].AllowGroupBy = Infragistics.Win.DefaultableBoolean.False;
        ugSetSummary(e, column, typeof(int), "Sum1P");
        
        //// Month 1 Allocated
        //// Caption: {Set by function}
        column = sd._fldResourceManagementAllocated1;
        e.Layout.Bands[parent].Columns[column].Header.Caption = "Allocated";
        e.Layout.Bands[parent].Columns[column].Header.VisiblePosition = headerPos++;
        e.Layout.Bands[parent].Columns[column].CellActivation =
        (_employee.IsAdministrator || _employee.IsProjectManager || _employee.IsResourceManager)
        ? Activation.AllowEdit
        : Activation.NoEdit;
        e.Layout.Bands[parent].Columns[column].Format = "##%";
        e.Layout.Bands[parent].Columns[column].MinWidth = e.Layout.Bands[parent].Columns[column].MaxWidth = 50;
        ugSetSummary(e, column, typeof(int), "Sum1A");
        
        // Rinse and repeat for 5 more months

    }

    Catch (Exception ex) { /* do stuff... */ }

}
    
    // Sets the Summary
public static void ugSetSummary(InitializeLayoutEventArgs e, string column, Type dataType, string SummaryKey,Infragistics.Win.HAlign align = Infragistics.Win.HAlign.Left)
{
        if (!e.Layout.Bands[sd._parentBand].Summaries.Exists(SummaryKey))
        {
            Type dt = e.Layout.Rows[0].Cells[column].Value.GetType();
            SummarySettings summary;
            summary = e.Layout.Bands[sd._parentBand].Summaries.Add(SummaryKey, SummaryType.Sum, e.Layout.Bands[sd._parentBand].Columns[column]);

            if (dt == typeof(double))
            {
                summary.DisplayFormat = "{0:F2}";
            }
            else if (dt == typeof(int))
            {
                summary.DisplayFormat = "{0:G}";
            }
            
            summary.Appearance.TextHAlign = align;
            e.Layout.Override.SummaryDisplayArea = SummaryDisplayAreas.Bottom;
    }
}

private void ugSetColumnGroups()
{
    UltraGridBand band = ugResourcePlanning.DisplayLayout.Bands[sd._parentBand];
    band.RowLayoutStyle = RowLayoutStyle.GroupLayout;
    
    UltraGridGroup firstGroup = band.Groups.Add("First Group", "");
    UltraGridGroup firstMonth = band.Groups.Add("Month 1", "July");
    UltraGridGroup firstMonth = band.Groups.Add("Month 1", "August");
    UltraGridGroup lastGroup = band.Groups.Add("Last Group", "");
    
    band.Columns[sd._fldResourceManagementProject].RowLayoutColumnInfo.ParentGroup = firstGroup;
    band.Columns[sd._fldResourceManagementResource].RowLayoutColumnInfo.ParentGroup = firstGroup;
    band.Columns[sd._fldResourceManagementGroup].RowLayoutColumnInfo.ParentGroup = firstGroup;
    band.Columns[sd._fldResourceManagementPlanned1].RowLayoutColumnInfo.ParentGroup = firstMonth;
    band.Columns[sd._fldResourceManagementCopy].RowLayoutColumnInfo.ParentGroup = lastGroup;
    
    firstMonth.Width = 100; 
}

private void FormManagement_Load(object sender, EventArgs e)
{
    try
    {
        // Setup UltraGrid
        ugResourcePlanning.DataSource = Prototype.ugGetResourcePlanning();
        ugSetColumnGroups();
    }
    catch (Exception ex) { sd.g_oErr.PersistDisplay(ex, true); }

}

Parents Reply Children
No Data