DataView RowFilter: Index was outside the bounds of the array.

G

Guest

Hi there,
I´m using the rowFilter property for filtering the rows in a DataView
object. If the filter is set to an inexistent value , that is, after
filtering i have 0 rows in the DataView, and I try to re-show all the rows
again by setting rowFilter = "", after setting the rowStateFilter i obtain
the "Index was outside the bounds of the array",.
If the dataview is not empty this code works fine. Here is the code:

currentView.RowFilter = stringFilter;

currentView.RowStateFilter = System.Data.DataViewRowState.CurrentRows;

if (currentView.Count == 0)
{
currentView.RowFilter = "";

}

Application.DoEvents();
 
M

Marko ®nidar

Hey there.
I dont know why this happens i get the same exception in datagrid in my code
i added :
i = customDataGrid1.CurrentRowIndex;

if (i==-1)
return; // skip the exception

Did u notice when u set your datagrid cells to read-only this does not
happen ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top