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.

Fit grid columns to the grid size

Thread ID:

Created:

Updated:

Platform:

Replies:

52070 Nov 21,2006 07:05 AM Nov 23,2006 01:04 AM Windows Forms 5
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On November 21, 2006 07:05 AM

Hi,

I want to have a Data Bound grid with a default behaviour that when I attach a table with N number of columns it should use all the size allocated to the grid.

Right now it's so happening that I have a larger grid size defined and columns are not covering all the defined area of the grid and it's looking odd.

I think this behaviour is present in GGC. Could you tell me which properties to set to get this behaviour?

Dheeraj
Replied On November 22, 2006 04:34 AM

Please provide any solution.. Basically I need an AutoFit behaviour: given the size of the grid and columns, the grid should atuomatically fit the columns using all the space provided.

Thanks,
Dheeraj

Administrator [Syncfusion]
Replied On November 22, 2006 05:02 AM

Hi Dheeraj,

Please use this sample code handling TableModel.QueryColWidth and SizeChanged event to see if that meets your requirements:

this.gridGroupingControl1.TableModel.QueryColWidth +=new Syncfusion.Windows.Forms.Grid.GridRowColSizeEventHandler(TableModel_QueryColWidth);
this.gridGroupingControl1.SizeChanged +=new EventHandler(gridGroupingControl1_SizeChanged);

private void TableModel_QueryColWidth(object sender, Syncfusion.Windows.Forms.Grid.GridRowColSizeEventArgs e)
{
int last = this.gridGroupingControl1.TableDescriptor.VisibleColumns.Count;
if(e.Index == (last + this.gridGroupingControl1.TableDescriptor.GroupedColumns.Count))
{
e.Size = (this.gridGroupingControl1.Width - ((this.gridGroupingControl1.TableDescriptor.VisibleColumns.TotalWidth -1)+ (this.gridGroupingControl1.TableDescriptor.GroupedColumns.Count * this.gridGroupingControl1.TableOptions.IndentWidth)));
e.Handled = true;
}
}

private void gridGroupingControl1_SizeChanged(object sender, EventArgs e)
{
this.gridGroupingControl1.TableControl.Refresh();
}

Best Regards,
Haneef

Dheeraj
Replied On November 22, 2006 05:16 AM

Hi Haneef,

Could you provide the code for DataBoundGrid. I don't see this snippet will compile for DataBoundGrid.

Thanks,
Dheeraj

Administrator [Syncfusion]
Replied On November 22, 2006 05:32 AM

Hi Dheeraj,

Here is a KB on percentage sizing the columns in a GridDataBoundGrid.
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=304

Best Regards,
Haneef

Dheeraj
Replied On November 23, 2006 01:04 AM

We are using this code with some modification. Thank you!

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.

;