Dan
  • Dan
  • Member Topic Starter
2014-07-14T06:53:01Z
Hi,

I've recently start a new job and my employer is using iGrid ActiveX 5.00.0089 (I've also tested today using the 5.00.0090 demo version and it has the same issues), and I've come across a few issues I can't figure out how to resolve. The applications are being developed in Visual Basic 6 SP6 on Windows 7.

The first is where the control selects all rows when repopulating. This appears to be due to rebuilding the grid data while a cell is being edited. Create a new application with a single form, add the control as iGrid1 and a command button as Command1, and in the form paste the following code:

Option Explicit

Private Sub Command1_Click()
    With iGrid1
        .Clear
        .RowCount = 3
        .CellValue(1, 1) = "test1"
        .CellValue(2, 1) = "test2"
        .CellValue(3, 1) = "test3"
    End With
End Sub

Private Sub Form_Load()
    iGrid1.AddCol "Test"
End Sub



Start up the application, click the command button. Click on any cell and press the Del key, which clears the cell. Then press the command button again - all the cells are highlighted grey as the grid doesn't have focus, when any cell is clicked all of them are highlighted in blue. It doesn't matter how many time the grid is rebuilt using Command1, all rows will be highlighted, and will need to be clicked twice each to clear the highlights, although they all get highlighted again when the command button is clicked whether a cell is in edit mode or not. Adding a ClearSelection method call doesn't do anything either.


The other issue is a much bigger problem. I require every cell to have a value unless it is the last row, in a single column grid. Add the following code to the above example:

Private Sub iGrid1_CellSelectionChange(ByVal lRow As Long, ByVal lCol As Long, ByVal bSelected As Boolean)
    'has selection moved away from an empty cell?
    If lRow > 0 And lCol > 0 And bSelected = False Then
        With iGrid1
            If .CellValue(lRow, lCol) = "" And lRow < .RowCount Then
                'delete this row, cell is empty
                .RemoveRow lRow
            End If
        End With
    End If
End Sub



Start up the application, select a row and press the Del key which clears it. Then move to another cell, using either the mouse or the up/down cursor keys. The application will crash, and is full reproducible.

Any help with these would be appreciated.

Regards,

Dan
Igor/10Tec
2014-07-15T09:21:28Z
Originally Posted by: Dan 

The first is where the control selects all rows when repopulating. This appears to be due to rebuilding the grid data while a cell is being edited.



I analyzed your scenario in the debugger, and I found the source of this problem. Yes, it's on our side, and will be fixed in the next public update of iGrid.

To request a workaround for this problem you can use without waiting for the release, contact us via email and provide your licensing information.


Originally Posted by: Dan 

The other issue is a much bigger problem. I require every cell to have a value unless it is the last row, in a single column grid.



Deleting/adding rows when cell properties are changed is not a good practice. When iGrid is in the middle of such a change, you can destroy the cell which is being changed, and accessing it later can cause crash. Events like CellSelectionChange should be used more like information events but not events you change column or row set from.

To reimplement this task without crash, try to use another event like AfterSelectionChange. Another technique of doing this is using a timer - start the timer in the CellSelectionChange event handler instead of removing the row, and do the removal work in the timer's event which is executed after all internal changes in iGrid.
Dan
  • Dan
  • Member Topic Starter
2014-07-15T11:00:47Z
Hi,

Thanks for the quick reply. I'll get my director to request the update as he has the licensing information.

As to the other issue, I've taken your suggestion of using AfterSelectionChange and it appears to be working without issues. I'm still figuring out how best to use the iGrid for the part of the application I'm working on, and I'll make a note about changing layouts being a potential cause of crashes like this. I'd rather not use timers as moving from old slow hardware to new ridiculously fast systems can make a big difference to the perceived performance, and finding a balance is quite difficult sometimes.

I must say that the built in editing features of the grid are making development a breeze so far, other than what I've stumbled on above. Hopefully over the next few months I'll be able to make use of a lot more features :)

Regards,

Dan
Igor/10Tec
2014-07-15T15:12:48Z
Dan, as for the timer, the idea is to use a timer with the minimal interval. In this case we use not the timer itself, but the fact that the timer's event is executed just after iGrid has finished all its operations.
Dan
  • Dan
  • Member Topic Starter
2014-07-16T06:11:01Z
Ah, I see what you mean now. I'd forgotten about the event sequencing, most of my development history has been spent writing COM DLLs for web applications which don't use events so I'm a little rusty :)

I'd still rather try to avoid timers though, as the application is likely to grow rapidly and get somewhat complex and having lots of timers kicking around in order to sequence codes could make long term maintenance difficult.