import DataGrid data to array

by kamil kunt   Last Updated January 14, 2018 12:26 PM

The first part of DataGrid is a checkbox. if checkbox is checked when importing that row values in array. My checkbox_checked function:

        string[][] fatura = new string[][] { };
    private void CheckBox_Checked(object sender, RoutedEventArgs e)
    {
        for (int i = 1; i < 7; i++)
        {
            DataGridCellInfo value = grid_borc.SelectedCells[i];
            DataGridBoundColumn column = value.Column as DataGridBoundColumn;
            FrameworkElement element = new FrameworkElement() { DataContext = value.Item };
            BindingOperations.SetBinding(element, TagProperty, column.Binding);
            int count = fatura.GetLength(0);
            if(fatura.GetLength(0)==0)
                fatura[count][i-1]= element.Tag.ToString();
            else
                fatura[count+1][i-1] = element.Tag.ToString();

        }
    }

error message:

Additional information: Index was outside the bounds of the array.



Related Questions


Save Array Data to datagrid and xml

Updated June 26, 2017 02:26 AM

Bind WPF DataGrid to one-dimensional array

Updated April 12, 2018 21:26 PM

Meshgrid a N-columned matrix in Numpy (or smth else)

Updated February 26, 2017 15:26 PM