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. Image for the cookie policy date

GridListContril and Column Width

Using a GridDataBoundGrid with a CellType of "GridListControl", when the drop down list drops down for the first time, the last column is much wider than it needs to be. After that, the column is a reasonable width. In the CurrentCellShowingDropDown event handler I''ve tried resixing the columns in the drop down grid but that doesn''t seem to work. Also, I''ve seen other posts where it looks like it''s possible to explicitly set the width of the entire (drop down) grid or perhaps even set the width of the last column but I don''t want to set it explicitly - I just want it to be a reasonable size (to fit) when it drops down. Has anyone seen this behaviour? Any ideas?

3 Replies

AD Administrator Syncfusion Team June 21, 2006 05:36 PM UTC

Hi Mark, You need to use this code in CellButton click and CurrentCellShowing DropDown event. Here is a code snippet. this.gridDataBoundGrid1.CurrentCell.MoveTo(e.RowIndex,e.ColIndex); GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell; GridDropDownGridListControlCellRenderer cr = cc.Renderer as GridDropDownGridListControlCellRenderer; if(cr != null) { cr.ListControlPart.AllowResizeColumns = false; int width = cr.ListControlPart.Grid.Model.ColWidths.GetTotal(0, cr.ListControlPart.Grid.Model.ColCount) + 16; cr.ListControlPart.Grid.Model.ColWidths.ResizeToFit(GridRangeInfo.Table(),GridResizeToFitOptions.IncludeHeaders); // testing: cr.ListControlPart.Size= new Size( width,91); } Here is a sample. http://www.syncfusion.com/Support/user/uploads/GridListControlResize_6a92b80a.zip Let me know if this helps. Best Regards, Haneef


MA Mark Atkinson June 21, 2006 07:22 PM UTC

No, this isn''t quite working for me. But I think I know why. When the GridListControl drops down, I''m setting some of the columns as hidden (cr.ListControlPart.Grid.Cols.Hidden[columnName] = true) I think the last column is taking up the slack of the newly hidden columns. Maybe calling ResizeTofit is actually considering the hidden columns in its calculations. >Using a GridDataBoundGrid with a CellType of "GridListControl", when the drop down list drops down for the first time, the last column is much wider than it needs to be. After that, the column is a reasonable width. > >In the CurrentCellShowingDropDown event handler I''ve tried resixing the columns in the drop down grid but that doesn''t seem to work. Also, I''ve seen other posts where it looks like it''s possible to explicitly set the width of the entire (drop down) grid or perhaps even set the width of the last column but I don''t want to set it explicitly - I just want it to be a reasonable size (to fit) when it drops down. > >Has anyone seen this behaviour? Any ideas?


AD Administrator Syncfusion Team June 21, 2006 10:03 PM UTC

Hi Mark, Before calling the ColWidths.GetTotal method, you need to set the cols.hidden[index] property to true. Here is a code snippet. this.gridDataBoundGrid1.CurrentCell.MoveTo(e.RowIndex,e.ColIndex); GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell; GridDropDownGridListControlCellRenderer cr = cc.Renderer as GridDropDownGridListControlCellRenderer; if(cr != null) { cr.ListControlPart.AllowResizeColumns = false; cr.ListControlPart.Grid.Model.Cols.Hidden[2] = true; cr.ListControlPart.Grid.Model.Cols.Hidden[3] = true; int width = cr.ListControlPart.Grid.Model.ColWidths.GetTotal(0, cr.ListControlPart.Grid.Model.ColCount) + 16; cr.ListControlPart.Grid.Model.ColWidths.ResizeToFit(GridRangeInfo.Table(),GridResizeToFitOptions.IncludeHeaders); // testing: cr.ListControlPart.Size=new Size( width, cr.ListControlPart.Size.Height); } Here is a modified sample. http://www.syncfusion.com/Support/user/uploads/GridListControlResize_f6dd038b.zip Let me know if this helps. Best Regards, Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon