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

Vertical scrollbar problem

Thread ID:

Created:

Updated:

Platform:

Replies:

67290 Aug 13,2007 01:26 PM UTC Aug 27,2007 11:35 PM UTC WinForms 3
loading
Tags: GridControl
Rahul Srivastava
Asked On August 13, 2007 01:26 PM UTC

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

haneefm [Syncfusion]
Replied On 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

Rahul Srivastava
Replied On 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.

haneefm [Syncfusion]
Replied On 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

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

;