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

Changing the top row index

I have an event handler for TopRowChanged(..) and a virtual grid. When I received the TopRowChanged(..) event, I do some calucation to reset the top row index of the grid to sync up with the data. So, I call gridControl.TopRowIndex within the TopRowChanged(..) handler. So, I am expecting TopRowChanged(..) handler called again. But for the second time, I have a boolean to check if I am calling it myself or not. If so, than I return at the top of the TopRowChanged handler. What I see so far is that TopRowChanged(..) call more than what I expected, 2 times, one when the user change the top row by scolling, and another one by the code (setting gridControl.TopRowIndex). The total number of times is 3, so my boolean is messed up, because I reset the boolean on the next iteration (2nd time) of the TopRowChanged(..) event callback. Is there any other method that I can reset the top row index without having TopRowChanged(..) called multiple times? Is this a bug to have TopRowChanged called more than twice? thanks, Patrick

7 Replies

AD Administrator Syncfusion Team December 22, 2003 07:48 PM UTC

Not sure about the TopRowChanged why it is firing again, but we do also have a TopRowChanging event that is raised before the rows are adjusted. You could set the TopRowIndex from within TopRowChanging and then set e.Cancel = true. TopRowChanging was added after 1.6.1.0. You will need to install the latest patch (1.6.1.8) in order to use this event. Stefan


PA Patrick December 23, 2003 12:37 PM UTC

I tried to set the m_GridControl.TopRowIndex in the TopRowChanging event handler, there is not effect, the property m_GridControl.TopRowIndex didn''t changed at all.


PA Patrick December 23, 2003 01:09 PM UTC

Yes I did set e.cancel = true. Let me try this again. When the user press the mouse in the scroll bar, I get a TopRowChanging event and than followed by TopRowChanged. In the TopRowChanged event handler, I call my grid control, m_GridControl.TopRowIndex = x. Now, the fun part begin. After I call m_GridControl.TopRowIndex = x, TopRowChanging immediately fired. What you are suggesting is to set m_GridControl.TopRowIndex = x in the TopRowChanging and e.cancel = true, right? I tried it already, but the value of m_GridControl.TopRowIndex won''t change at all. -patrick


PA Patrick December 23, 2003 01:10 PM UTC

Yes I did set e.cancel = true. Let me try this again. When the user press the mouse in the scroll bar, I get a TopRowChanging event and than followed by TopRowChanged. In the TopRowChanged event handler, I call my grid control, m_GridControl.TopRowIndex = x. Now, the fun part begin. After I call m_GridControl.TopRowIndex = x, TopRowChanging immediately fired. What you are suggesting is to set m_GridControl.TopRowIndex = x in the TopRowChanging and e.cancel = true, right? I tried it already, but the value of m_GridControl.TopRowIndex won''''t change at all. -patrick


AD Administrator Syncfusion Team December 23, 2003 01:11 PM UTC

Did you also set e.Cancel = true ? Otherwise the grid thinks it should continue with its default behavior and scroll the grid to the originally intended scroll position. When you call TopRowChanged be also aware that this will trigger another TopRowChanging event. Stefan


PA Patrick December 23, 2003 01:18 PM UTC

Something is wrong with the time stamp. Please read my previous post.


AD Administrator Syncfusion Team December 23, 2003 04:28 PM UTC

There is a check in DoScroll that prevents the call to TopRowIndex from having any effect... But, you can try override OnVScroll as follows: protected override void OnVScroll(object sender, ScrollEventArgs se) { if (se.NewValue == 10) { se.NewValue = 15; } base.OnVScroll (sender, se); } If you have 2.0 beta, there is also e VerticalScroll event if you do not want to derive and override. Stefan

Loader.
Live Chat Icon For mobile
Up arrow icon