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. Image for the cookie policy date
close icon

Vertical scrollbar problem

Hi,

I am using Syncfusion DataBoundGrid.

the problem is that databound grid is not maintaing the vertical and horizontal scroll bar positions when i am re assigning the data to the grid.

here is what i am doing..

private void UpdateGrid(DataSet ds)
{
lock(dsParentChild)
{
grdData.Binder.ResetHierarchyLevels();
grdData.BeginUpdate();
grdData.Binder.SuspendBinding();
grdData.VScrollBar.BeginUpdate();
dsParentChild = ds;
grdData.DataMember = "ParentTable";
grdData.DataSource = dsParentChild;
grdData.Binder.AddRelation("ParentID");
grdData.VScrollBar.Value = vs;
grdData.VScrollBar.EndUpdate();
grdData.Binder.ResumeBinding();
grdData.EndUpdate();

}
}

int vs = 0;
private void grdData_VerticalScroll(object sender, System.Windows.Forms.ScrollEventArgs e)
{
vs= e.NewValue;
}

the grid flickers as it first shows the first records, then scrolls to the required position.

Please let me know the solution for it.

Thanks and Regards,

Rahul Srivastava

3 Replies

HA haneefm Syncfusion Team August 13, 2007 03:20 PM UTC

Hi Rahul,

You can try changing the ShowCurrentCellBorderBehavior with the BeginUpdate / EndUpdate to reduce the flickering. The black triangle movement can be avoided by using the FreezePainting property in a derived grid. Please refer this sample for more details and let me know if this helps.

GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
int row = cc.RowIndex;
int col = cc.ColIndex;

this.gridDataBoundGrid1.FreezePainting = true;
this.gridDataBoundGrid1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.HideAlways;

this.gridDataBoundGrid1.BeginUpdate();
this.gridDataBoundGrid1.DataSource = GetDataTable();
this.gridDataBoundGrid1.EndUpdate();
this.gridDataBoundGrid1.Refresh();

cc.MoveTo(row, col, GridSetCurrentCellOptions.ScrollInView);
this.gridDataBoundGrid1.Focus();

this.gridDataBoundGrid1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.AlwaysVisible;
this.gridDataBoundGrid1.FreezePainting = false;

Sample : Retainsthefocusinagrid.zip

Best regards,
Haneef


RS Rahul Srivastava August 14, 2007 07:43 AM UTC

Hi,

The solution that you sent makes sure that the current cell is in visible area. but it doesn't scroll to the exact location as it was.

In other words, suppose I select a cell in somewhere middle of the display area of the grid. Next time, I am assigning data to the datagrid, the current cell goes to the bottom of the grid, because we are only making sure that the current cell is visible.

I also want the scroll position to remain same.

Please let me know the solution for the same.

Thanks and Regards,

Rahul Srivastava

P.S : I am using Visual Studio 2003, so please send solutions in VS 2003 format.


HA haneefm Syncfusion Team August 27, 2007 11:35 PM UTC

Hi Rahul,

Try setting the TopRowIndex of the grid after modifying the underlying datasource of the grid. Below is a code snippet that shows this.

[c#]
int t_iTopRowIndex = this.gridDataBoundGrid1.TopRowIndex;
////////
GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
int row = cc.RowIndex;
int col = cc.ColIndex;

this.gridDataBoundGrid1.FreezePainting = true;
this.gridDataBoundGrid1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.HideAlways;

this.gridDataBoundGrid1.BeginUpdate();
this.gridDataBoundGrid1.DataSource = GetDataTable();
this.gridDataBoundGrid1.EndUpdate();
this.gridDataBoundGrid1.Refresh();

cc.MoveTo(row, col, GridSetCurrentCellOptions.ScrollInView);
////////
this.gridDataBoundGrid1.TopRowIndex =t_iTopRowIndex;
this.gridDataBoundGrid1.Focus();
this.gridDataBoundGrid1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.AlwaysVisible;
this.gridDataBoundGrid1.FreezePainting = false;

Please refer the modified sample for implementation and let me know if this helps.
Forum_40341_3Feb_RetainFocus.zip

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon