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

force a scroll to row

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!

9 Replies

AD Administrator Syncfusion Team December 15, 2005 01:14 AM UTC

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();


EW Eric Weber December 15, 2005 02:18 PM UTC

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!


AD Administrator Syncfusion Team December 15, 2005 04:27 PM UTC

>>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).


EW Eric Weber December 15, 2005 06:07 PM UTC

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 }


EW Eric Weber December 15, 2005 06:11 PM UTC

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


AD Administrator Syncfusion Team December 15, 2005 07:07 PM UTC

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?


EW Eric Weber December 15, 2005 09:24 PM UTC

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?


EW Eric Weber December 15, 2005 09:27 PM UTC

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


AD Administrator Syncfusion Team December 15, 2005 11:23 PM UTC

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?

Loader.
Live Chat Icon For mobile
Up arrow icon