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.
Unfortunately, activation email could not send to your email. Please try again.

GridListContril and Column Width

Thread ID:

Created:

Updated:

Platform:

Replies:

45462 Jun 21,2006 12:40 PM Jun 21,2006 06:03 PM Windows Forms 3
loading
Tags: GridControl
Mark Atkinson
Asked On June 21, 2006 12:40 PM

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?

Administrator [Syncfusion]
Replied On June 21, 2006 01:36 PM

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

Mark Atkinson
Replied On June 21, 2006 03:22 PM

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?

Administrator [Syncfusion]
Replied On June 21, 2006 06:03 PM

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

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.

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.

;