Tricking scrollbar into scrolling through unloaded items
I have a potentially huge xml data file present on a server. I would like the data to be loaded into a datagrid on a client machine to allow the user to scroll through the items in the xml file and select one. Due to the potential huge size of the data I dont really want to get the entire xmlfile and load it into the datagrid. For this reason Im trying to give the impression of all the data being loaded without actually loading it all.
Im doing this by capturing the scroll event from the scroll bar and requesting the rows currentScrollbarvalue to ( currentScrollbarvalue + number of records to display ) loading the xml into an xmldataprovider and setting this to the datasource of the datagrid. The issue I have is that my datagrid flashes grey occasionally when scrolling. Im assuming this is because it is rendering the datagrid inbetween the datasource being assigned?
Basically Im wondering if I am doing this in the correct way and if so if it would be possible to stop this flashing.
Please let me know if you need antyhing explaining in more detail or any code posting.
use the VirtualMode property. This way the grid items will be only made visible when they are made visible. You then use implement the event CellValidating to fill the list. See http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.virtualmode.aspx
For DataGrid you need to set the EnableRowVirtualization property to true. This only works with data binding.