Horizontal Scrolling in GridDataBoundGrid
I am using a GridDataBoundGrid that is being bound to a DataTable with n columns. Whenever I set a frozen count of x, and scroll horizontally, the scrolling freezes at (n-x) columns.
I am able to fix this problem by setting the HScrollPixel property to false. However, when I do this, there is an empty space to the right of the last column, which I need to get rid of.
Is there any way to prevent the scrolling freeze AND get rid of the empty space?
I am attaching a sample application to demonstrate the problem. Right click to freeze columns and set the number of cols.
ScrollTest_2371.zip
SIGN IN To post a reply.
7 Replies
AD
Administrator
Syncfusion Team
May 16, 2005 02:11 PM UTC
Trying to freeze more columns than are visible is a problem. And I think this is causing the problem you are seeing. Here is a little tweaking of your code to try to prevent this.
private void Form1_Load(object sender, System.EventArgs e)
{
_grid.Model.Rows.HeaderCount = 0;
_grid.Model.Cols.HeaderCount = 1;
_grid.DataSource = _createTable(25, 50);
_grid.Model.Cols.SetFrozenCount(1, true);
}
private void menuFreeze_Click(object sender, System.EventArgs e)
{
int rowIndex, colIndex;
this._grid.PointToRowCol(_rightClickPoint, out rowIndex, out colIndex);
if (colIndex > this._grid.Model.Cols.HeaderCount
&& this._grid.Model.ColWidths.GetTotal(0,colIndex) < this._grid.ClientSize.Width)
{
this._grid.Model.Cols.FrozenCount = colIndex;
_grid.LeftColIndex = colIndex + 1;
}
}
AD
Administrator
Syncfusion Team
May 16, 2005 02:42 PM UTC
Here is a forum thread that I think discusses the behavior you want to get.
http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=19149
RM
Ramya Modukuri
May 16, 2005 04:15 PM UTC
This code has a different issue. Run the app and resize the form so that you can see exactly 10 columns (out of 25). Now freeze the first 6 columns. When you scroll horizontally, the last column you can see when the scrollbar is all the way to the right, is Col22. However, if you increase your form size, all the columns are visible. This is misleading. When the scrollbar hits the max position, col 25 should be visible.
I am looking through the other message, but the issue there is with the current position being reset when columns are frozen. I don''t care if the scroll bar jumps back to the start position when I freeze, as long as scrolling works as expected with frozen columns.
I just need the grid to behave such that when the first x columns are frozen, that I can still scroll to the last column without having to resize my window, having to use the arrow keys or having an empty space to the right of the last column.
Thanks.
RM
Ramya Modukuri
May 16, 2005 09:13 PM UTC
Any updates on this?
>Here is a forum thread that I think discusses the behavior you want to get.
>
>http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=19149
AD
Administrator
Syncfusion Team
May 16, 2005 09:15 PM UTC
I see the problem, but do not have a suggestion yet.
AD
Administrator
Syncfusion Team
May 17, 2005 11:52 AM UTC
Here is a work around until we can get a release out that has this corrected. The idea is to use HScrollPixel=false so the scrolling works ok, but to extend the right-most column to fill up the empty space on the right side of the grid that you do not want to see. Maybe this will serve your needs until we get this corrected.
//at the bottom of form.load
this._grid.HScrollPixel = false;
this._grid.Model.QueryColWidth += new GridRowColSizeEventHandler(Model_QueryColWidth);
this._grid.HScrollBar.Scroll += new ScrollEventHandler(HScrollBar_Scroll);
//the handlers
private void HScrollBar_Scroll(object sender, ScrollEventArgs e)
{
if(this._grid.ViewLayout.LastVisibleCol == this._grid.Model.ColCount)
this._grid.InvalidateRange(GridRangeInfo.Col(this._grid.ViewLayout.LastVisibleCol));
}
private void Model_QueryColWidth(object sender, GridRowColSizeEventArgs e)
{
if(e.Index == this._grid.Model.ColCount)
{
//starts at 1 as headers are hidden...
int w = this._grid.Model.ColWidths.GetTotal(1, this._grid.Model.Cols.FrozenCount)
+ this._grid.Model.ColWidths.GetTotal(this._grid.LeftColIndex, e.Index - 1);
e.Size = this._grid.ClientSize.Width - w;
if(e.Size > 0)
e.Handled = true;
}
}
RM
Ramya Modukuri
May 17, 2005 02:25 PM UTC
Thanks! Looks like this works.
SIGN IN To post a reply.
- 7 Replies
- 2 Participants
-
RM Ramya Modukuri
- May 16, 2005 01:40 PM UTC
- May 17, 2005 02:25 PM UTC