Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
UltraWinGrid scrolling to bottom with datatable
posted

After getting a DataTable back from a stored procedure call, I'm adding empty rows to the datatable so the user can enter more data into it. The issue is that after assigning the datatable to the ultragrid datasource property, the scrollbar moves all the way to the end. The user will not be able to see the existing rows that were populate in the datatable by the stored procedure call.

Is there a way to have the active row as the first row or set the scroll bar to the top?

Here is the code:

dtRBMOverride = vprDataTable.LoadSP("rbmSelOverride", sqlParams.ToArray());
for (int i = 0; i < 99; i++)
{
var row = dtRBMOverride.NewRow();
dtRBMOverride.Rows.Add(row);
}
ultraGrid1.DataSource = dtRBMOverride;


This is what I have tried so far with no success:

ultraGrid1.Rows[0].Selected = true;
ultraGrid1.DisplayLayout.RowScrollRegions[0].ScrollPosition = 0;
ultraGrid1.DisplayLayout.RowScrollRegions[0].Scroll(RowScrollAction.Top);
ultraGrid1.ActiveRowScrollRegion.Scroll(RowScrollAction.Top);
this.ultraGrid1.DisplayLayout.RowScrollRegions[0].FirstRow = this.ultraGrid1.ActiveRow.ParentRow;

private void ultraGrid1_InitializeLayout(object sender, InitializeLayoutEventArgs e)
{
e.Layout.Override.AllowMultiCellOperations = Infragistics.Win.UltraWinGrid.AllowMultiCellOperation.All;
e.Layout.ScrollBounds = ScrollBounds.ScrollToFill;
}

Parents
No Data
Reply
  • 28945
    Offline posted
    Hello,
    Thank you for contacting Infragistics.
    I recommend using the AddNewRow feature of the UltraWinGrid. This might be more efficient and preferable than adding empty rows to your DataTable. You can also fix the AddNewRow at the top, no matter what scroll position.
    Alternatively, you can also add a new row to the grid's Band collection via the AddNew method.
    Naturally, adding a new row with the AddNew method will also insert the row to the bottom and resulting in scrolling to happen automatically.
    You can address this by moving the row and performing ScrollRowIntoView:

                
    UltraGridRow row = this.ultraGrid1.DisplayLayout.Bands[0].AddNew();
    row.ParentCollection.Move(row, 0);
    this.ultraGrid1.ActiveRowScrollRegion.ScrollRowIntoView(row);
    For more details regarding the AddNew method please visit our online help documentation
    I attached a sample that demonstrates the AddNewRow functionality. In addition I added the code above above in a button's click event, commented out. It's commented out because the grid will simply ignore the AddNew method when there is already an AddNewRow.
    Let me know if you have any questions.
Children
No Data