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. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Stack overflow exception using QueryColWidth

Thread ID:

Created:

Updated:

Platform:

Replies:

20251 Oct 13,2004 09:19 AM UTC Oct 13,2004 03:59 PM UTC WinForms 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On October 13, 2004 09:19 AM UTC

I''m using the following code in the QueryColWidth event of a data bound grid. if (e.Index == 2) { int width = this.gridDocuments.Model.ColCount <= 0 ? 0 : (this.gridDocuments.Model.ColWidths.GetTotal(0, this.gridDocuments.Model.ColCount-1)-this.gridDocuments.Model.Cols.Size[2]); e.Size = this.gridDocuments.ClientRectangle.Width-width; e.Handled = true; } The intent (based upon postings in this forum) is to resize the second column based on the widths of the other column. The example this is borrowed from was intended to resize the last column. I want to resize a column in the middle of the other columns. The problem is that this results in a stack overflow exception in the grid. If I change the code to use the last column in the grid it works fine.

Administrator [Syncfusion]
Replied On October 13, 2004 01:28 PM UTC

You cannot try to reference this.gridDocuments.Model.Cols.Size[2]); from within the code when e.Index = 2. The reason is that trying to retrieve this.gridDocuments.Model.Cols.Size[2]) trigeers a call to QueryColWidth with e.Index = 2. So, you get into a recursive call situation which leads to teh stack overflow. So, instead of int width = this.gridDocuments.Model.ColCount <= 0 ? 0 : (this.gridDocuments.Model.ColWidths.GetTotal(0, this.gridDocuments.Model.ColCount-1)-this.gridDocuments.Model.Cols.Size[2]); try
if(e.Index == 2)
{
	int width = this.gridDocuments.Model.ColWidths.GetTotal(0, 1);
	if(this.gridDocuments.Model.ColCount > 2)
		width += this.gridDocuments.Model.ColWidths.GetTotal(3,this.gridDocuments.Model.ColCount);
	e.Size = this.gridDocuments.ClientRectangle.Width - width;
	e.Handled = true;
}

Administrator [Syncfusion]
Replied On October 13, 2004 03:28 PM UTC

Thank you, that worked. Not sure what I was thinking there.

Administrator [Syncfusion]
Replied On October 13, 2004 03:59 PM UTC

Related question: This solution works, but the column headings don''t redraw very well once you resize a particular column. Is there something I can do to fix that?

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.

Warning Icon 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.Close Icon

;