We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Current Cell not pointing to valid cell?

I''m having a couple of issue involving deleting rows from the underlying data for a GDBG. My GDBG is bound to a custom collection, CustomerIncomes, which contains CustomerIncome objects. 1) If the CurrentCell is on the bottom row of the grid and I remove that CustomerIncome object from CustomerIncomes (and then do grid.RefreshRange(grid.ViewLayout.VisibleCellsRange, True)), the CurrentCell.RowIndex is a row off the bottom of the grid now. How can I tell if CurrentCell.RowIndex is a valid row or not? 2) If I have three rows in the GDBG ("A", "B", and "C") with the CurrentCell in the middle row ("B"), and I remove that CustomerIncome object from CustomerIncomes and do a RefreshRange(...), the grid ends up showing rows "A" and "C" in the first two rows, and a partial "ghost" image of row "C" in a third row (see attached screen shot). Below is my code for my DeleteData() method. Private Sub DeleteData() With dtgEmployerInfo If m_Incomes.Count > 0 AndAlso dtgEmployerInfo.CurrentCell.RowIndex > -1 Then Dim Index As Integer = .CurrentCell.RowIndex Dim Msg As String = String.Format( _ "Are you sure you want to delete the following Income?{0}{0}" & _ " Income Source: {1}{0}" & _ " Employer Name: {2}{0}" & _ " Work Phone: {3}{0}" & _ " Extension: {4}{0}" & _ " Income Range: {5}", _ ControlChars.CrLf, _ .Item(Index, .Binder.NameToColIndex(INCOME_TYPE_COLUMN)).CellValue.ToString, _ .Item(Index, .Binder.NameToColIndex(EMPLOYER_NAME_COLUMN)).CellValue.ToString, _ .Item(Index, .Binder.NameToColIndex(WORK_PHONE_COLUMN)).CellValue.ToString, _ .Item(Index, .Binder.NameToColIndex(EXTENSION_COLUMN)).CellValue.ToString, _ .Item(Index, .Binder.NameToColIndex(INCOME_RANGE_COLUMN)).CellValue.ToString) Dim Result As MsgBoxResult = MsgBox(Msg, MsgBoxStyle.YesNo, "Delete Income?") If Result = MsgBoxResult.Yes Then Dim Position As Integer = .Binder.RowIndexToPosition(Index) If Position < 0 Or Position > m_Incomes.Count - 1 Then Throw New ApplicationException("Invalid Income Index. Cannot delete selected Income.") End If m_Incomes.Remove(m_Incomes(Position)) If m_Incomes.Count > 0 Then .CurrentCell.MoveTo(1, 1) .CurrentCell.ScrollInView() End If .RefreshRange(.ViewLayout.VisibleCellsRange, True) DisplayData() End If End If End With End Sub ----- Lee Perkins

4 Replies

AD Administrator Syncfusion Team June 9, 2004 11:32 AM

1) compare the CurrentCell.RowIndex to grid.Model.RowCount to see if it is valid. 2) Did not see your picture, but if it is only the current cell that is ''ghosting'', the try this. Before you delete a row, try calling grid.CurrentCell.EndEdit() and grid.Binder.EndEdit() to make sure there are no pending changes when you delete the row. If it is the whole row that is ghosting, then try calling grid.Invalidate() before the refreshrange call to see if that clears things up.


LP Lee Perkins June 9, 2004 11:35 AM

Thanks for the suggestions, I''ll try them. Also, here''s the image. It''s the whole row that''s ghosting, with a chunk out of the middle. You''ll have to see the image to get it. :) GhostRow_1603.zip ----- Lee Perkins


LP Lee Perkins June 9, 2004 11:39 AM

Both suggestions worked like a champ. Thanks! ----- Lee Perkins


LP Lee Perkins June 9, 2004 11:39 AM

Both suggestions worked like a champ. Thanks! ----- Lee Perkins

Loader.
Live Chat Icon For mobile
Up arrow icon