private int GetLastRowIndex(SfDataGrid dataGrid)
        {
            if (dataGrid.View.Records.Count == 0)
            {
                return(-1);
            }
            var footerCount = dataGrid.GetUnboundRowsCount(VerticalPosition.Bottom, true);
            int count       = 0;
            int index       = dataGrid.RowCount - (dataGrid.TableControl.GetTableSummaryCount(VerticalPosition.Bottom) + footerCount + 1);

            if (dataGrid.AddNewRowPosition == RowPosition.Bottom)
            {
                index -= 1;
            }
            if (dataGrid.FilterRowPosition == RowPosition.Bottom)
            {
                index -= 1;
            }
            for (int start = index; start >= 0; start--)
            {
                if (!dataGrid.TableControl.RowHeights.GetHidden(start, out count))
                {
                    return(start);
                }
            }

            return(index);
        }