Hi,
I am using WinGrid 2008 ver8.1. I am using DataTable as a source for the Grid. I have set the LoadStyle of the grid to LoadOnDemand. I have used the row initialising event to set the image for cells in the first column. I have some 10000 records in the table.
height of the grid , i have set such that i can see only10 records at a time. on using the scroll bar, the other rows are shown. which is fine.
say the user scrolls to 20 th row. and clicks a button to reload the grid. I want the 20th row to be selected. Since i am showing 10 rows at a time, when i try to loop through the rows to select 20th row, the grid stops working in LoadOnDemand mode and all the rows get loaded in the grid.
1.How do i select the 20th row without affecting the LoadOnDemand?
2.At any point of time if i can to check the contents of a cell in the row which is visible, in which collection should i loop?
i checked the VisibleRowCount property for looping, but its count is same as the total no of rows in the table. Is there any property which will give see the collection of rows that is currently visible in the grid area?
Any Help will be appriciated.
Thanks in advance
Casey
Hi Casey,
You lost me again right here:
CaseyR said:Since only 10 rows are loading, is there any event that can be used to forcilby load the next 10 or how much ever in case the row to select is not visible in the currently loaded rows in the grid.
You don't need any special method for this, you can simply loop through the grid rows. Once you attempt to access the row, the grid will ask the data source for the data.
InitializeRow will not work, because it won't fire for any rows that are you out view.
CaseyR said:if i directly set 20th row to be selected in the method where i am setting the data source or loop through the grid's row collection to locate the row , the LoadOnDemand is failing, as the entire data of the table is getting loaded to the grid.
Looping through the grid rows should not force all rows in the grid to get created, unless you loop code is looping through every row in the grid instead of stopping when it finds the correct row. What kind of loop are you using? What are you doing inside the loop?
Hi Mike,
Thanks for the reply.
What i wanted to say is, the user scrolls to 20th row and selects that row. There is a button, when the user clicks that button, the grid should be reloaded with data, but this time, the 20th row should be loaded and selected, without affected the LoadOnDemand.
My table has an Id column. I am storing that Id value when the user selects that row.
Since only 10 rows are loading, is there any event that can be used to forcilby load the next 10 or how much ever in case the row to select is not visible in the currently loaded rows in the grid.
I have written the code for selecting the row in the row_initilaising event, this will work as long as the row to be selected programmatically is within first 10 loaded rows.This i am doing by checking the Id value as and when the row is getting loaded.
if i directly set 20th row to be selected in the method where i am setting the data source or loop through the grid's row collection to locate the row , the LoadOnDemand is failing, as the entire data of the table is getting loaded to the grid.
How do i load the next no of rows incase it is not visible and then search for the id in that to select , without affecting the LoadOnDemand?
Thanks ,
CaseyR said:say the user scrolls to 20 th row. and clicks a button to reload the grid. I want the 20th row to be selected. Since i am showing 10 rows at a time, when i try to loop through the rows to select 20th row, the grid stops working in LoadOnDemand mode and all the rows get loaded in the grid.
You kinda lost me here. If you are only looping up to the 20th row, then the grid should only be loading the rows that you accessed. What exactly are you doing that causes the grid to load all of the rows?
To get a list of the rows visible on the screen, you would use grid.ActiveRowScrollRegion.VisibleRows.