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

Docking problems with Grid control?

Thread ID:

Created:

Updated:

Platform:

Replies:

852 Aug 23,2002 07:57 PM UTC Aug 26,2002 01:35 PM UTC WinForms 4
loading
Tags: GridControl
Rollan Mosko
Asked On August 23, 2002 07:57 PM UTC

I'm having bazarre docking problems with the grid control. The grid's scroller controls dock fine with the Parent panel control; however, the grid separates from its scrollers as the window enlarges. Things look fine if I reduce the width or height of my form though. I have a form that includes a user control that contains left and right panels in Explorer style with a treeview on the left and the grid on the right and a splitter in the middle. The Treeview is happy when the form changes size but the grid looks strange. thanks, Rollan

Clay Burch [Syncfusion]
Replied On August 24, 2002 08:43 AM UTC

Rollan, I am not sure I understand exactly what you are describing. Is it that the number of columns and rows are insufficient to fill the clientarea that is enlarged as the window is sized because the grid's DockStyle is set to Fill? If so, then this behavior is as expected since the grid's scrollbars are at the edge of the grid's clientarea. It is just the grid does not have enough rows/columns to occupy the entire clientarea. There would be a couple of ways of avoiding this look. One might be to only dock the grid to the left and top, and not use Fill. In this case, you would also want to set the grid's clientarea to the size of the area that would have been filled. Another way might be to dynamically size the right-most column so it fills any empty clientspace. The GridListControl has a property that sets this behavior. You implement it by handling the QueryColWidth event, and if the request is for the last column, provide the exact width that would fill any empty clientarea. You can see the exact code in the QueryColWidth handler of the GridListControl class. If this does not explain what you are seeing, can you provide more details?

Rollan Mosko
Replied On August 24, 2002 06:29 PM UTC

Hi Clay, Thanks for the reply- working on a Saturday- I'm impressed! What I'm trying to do is grow the rightmost column so it stretches as the control widens. I have just 2 columns in my sample grid. I tried your suggestion of handling the QueryColWidth() event. What I do is get the GridSize and then calculate what the right column should be by subtracting the 1st column from the size of the grid. I'm not sure how to accomplish the column size query for the first column though. I was looking at the supplied samples and noticed the virtual treegrid sample. I was thinking it might be beneficial for me and others if the necessary logic was added to that sample to show how we can expand the D column appropriately to always fill the right part of the grid. That mimics what I'm trying to do quite well.

Clay Burch [Syncfusion]
Replied On August 24, 2002 09:08 PM UTC

Rollan, Below is the code to expand the right column in the VirtTreeGrid sample. In implementing this expandable right column in this particular sample, there is a refresh problem as you size the grid larger. You can add a SizedChanged handler, and redraw the last column to handle this refresh problem. -Clay (still working on Sat...)
void GridQueryColWidth(object sender, GridRowColSizeEventArgs e) 
{
	if( e.Index == 1)
		e.Size = 200;
	else if(e.Index == gridControl1.ColCount)//fill grid with last col
	{
		int width = gridControl1.ColWidths.GetTotal(0, gridControl1.ColCount-1);
		e.Size = Math.Max(20, gridControl1.ClientRectangle.Width-width);
	}
	else if (e.Index > 0)
		e.Size = 100;
	else
		e.Size = 0;//hide the header // 30;
	e.Handled = true;
}

private void gridControl1_SizeChanged(object sender, System.EventArgs e)
{
	gridControl1.RefreshRange(GridRangeInfo.Col(gridControl1.ColCount));
}

Rollan Mosko
Replied On August 26, 2002 01:35 PM UTC

Hi Clay, Thanks a bunch. Your code fixes the problem pretty well. I needed to also factor in the DockPadding used in the grid's parent window (a panel) to reduce a little gap between the vertical scroller and the right column. For some reason I needed to factor 4x the doc padding instead of 2x like I would have expected. Don't know why that's needed, but 4x works. thanks, Rollan

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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

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

;