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.
Unfortunately, activation email could not send to your email. Please try again.

force a scroll to row

Thread ID:

Created:

Updated:

Platform:

Replies:

38558 Dec 14,2005 06:43 PM Dec 15,2005 06:23 PM Windows Forms 9
loading
Tags: GridControl
Eric Weber
Asked On December 14, 2005 06:43 PM

I''m using a GGC. After I add an object to the arraylist that the control is bound to, I then want the grid to scroll to the row that was just inserted. How do I do this? thanks!

Administrator [Syncfusion]
Replied On December 14, 2005 08:14 PM

Get the index of the new object in the ArrayList (it is returned by the ArrayList.Add call). Then try code like: grid.Table.Records[index].SetCurrent();

Eric Weber
Replied On December 15, 2005 09:18 AM

Is your assumption that the newly added array list object will appear at the bottom of the grid? In our case, this isn''t necessarily true due to the grid being sorted. This might be a better question... How do I force a grid (GGC) to scroll to the currently selected row (a row that I''ve programmatically selected)? thanks!

Administrator [Syncfusion]
Replied On December 15, 2005 11:27 AM

>>currently selected row (a row that I''''ve programmatically selected)? I am not sure what this means? (There might be many selected records in a grid). Can you show me the code you use programmatically set the record current? The reason I ask is that if you know the GridRecord object, then you can just call gridRecord.SetCurrent() to scroll record visible (and make it current).

Eric Weber
Replied On December 15, 2005 01:07 PM

Here you go...... public void AddTraderComment(object sender, EventArgs e) { TraderComment tc = new TraderComment(); int index = sci.TraderComments.Add(tc); //clear all selected records in grid grid.TableControl.Table.SelectedRecords.Clear(); //select the new row that was just added foreach(Record record in grid.TableControl.Table.Records) { TraderComment tc2 = (TraderComment)record.GetRecord().GetData(); if(tc2.Id == tc.Id) { grid.TableControl.Table.SelectedRecords.Add(record); } } //now I need to force scroll to the newly added, newly selected row }

Eric Weber
Replied On December 15, 2005 01:11 PM

adding... Record.SetCurrnt() right after... grid.TableControl.Table.SelectedRecords.Add(record) didn''t work

Administrator [Syncfusion]
Replied On December 15, 2005 02:07 PM

I think calling record.SetCurrent should work. When you tried that, were any excpetions shown in your output window? What kind of thing is sci.TraderComments? Does it implement IBindingList?

Eric Weber
Replied On December 15, 2005 04:24 PM

sci.TraderComments is an instance of TraderCommentList. This is what the grid is bound to. TraderCommentList inherits from BaseBindingList. BaseBindingList inherits from CollectionBase and implements IBindingList. public class TraderCommentList : BaseBindingList public abstract class BaseBindingList : CollectionBase, IBindingList Is there an IBindingList property that I need to set?

Eric Weber
Replied On December 15, 2005 04:27 PM

forgot to mention......no errors in output window

Administrator [Syncfusion]
Replied On December 15, 2005 06:23 PM

Here is sample that uses an ArrayList of objects. It has a button click event that alternately adds or inserts a new item in the ArrayList and making the newly inserted or added item current. http://www.syncfusion.com/Support/user/uploads/GGC_Copy_9bf3b3e.zip In this sample, calling record.SetCurrent is all that is required. I am using version 4.1. Does this work for you? Can you tell us how to see teh problem in this sample?

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.

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.

;