Egrid32 - How to set the column count and row count at run time ?

Started by Roy Chan, November 10, 2011, 06:06:37 AM

Previous topic - Next topic

Roy Chan

Dear Sir,

How can I change the egrid32 column count and row count at run time ? I can not find any information in the egrid32 help file. I only can change the caption  at design time to adjust the column count and row count.


Thanks.

Roy
iniSoft System Technology Limited
Lenovo ThinkPad SL410 4GB Ram,
Windows XP SP3 / PBWin 10 & FireFly 3.51

James Padgett


Michael Shillito

#2
Roy

See Egrid help file:-

Commands/Grid Commands/Rows & Columns

EG_INSERTROW
EG_APPENDROW

EG_INSERTCOLUMN
EG_APPENDCOLUMN

This would add 50 rows to the bottom of your grid

SendMessage  HWND_FORM1_EGRID321,%EG_APPENDROW,50,0


All the commands are in there

Hope this helps

Michael



Roy Chan

I write two functions for change row count and column count.

Sub EG_SetColumnCount( ByVal hWndControl As Dword,NewColumnCount As Long,SizeOfNewColumns As Long)
    Local ColumnCount As Long   
    ColumnCount=SendMessage(hWndControl, %EG_GETMAXCOLUMNS, 0, 0)
   
    If newcolumncount > columncount Then
        SendMessage(hWndControl, %EG_APPENDCOLUMN,newcolumncount-columncount, SizeOfNewColumns&)

    ElseIf newcolumncount < columncount Then
        SendMessage(hWndControl, %EG_KILLCOLUMN, columncount - newcolumncount, 0)

    End If

End Sub


Sub EG_SetRowCount( ByVal hWndControl As Dword,NewRowCount As Long, SizeOfNewRows As Long)
    Local RowCount As Long
    RowCount = SendMessage(hWndControl, %EG_GETMAXROWS, 0, 0)

    If newrowcount > rowcount Then
        SendMessage(hWndControl, %EG_APPENDROW, newrowcount - rowcount, SizeOfNewRows&)

    ElseIf newrowcount < rowcount Then
        SendMessage(hWndControl, %EG_KILLROW, rowcount - newrowcount, 0)
   
    End If

End Sub
iniSoft System Technology Limited
Lenovo ThinkPad SL410 4GB Ram,
Windows XP SP3 / PBWin 10 & FireFly 3.51

Brian Chirgwin


Roy Chan

Since I can not set the row count to 0. So I modified the code to hide the first row when I set the row count to 0.


Sub EG_SetColumnCount( ByVal hWndControl As Dword,NewColumnCount As Long,SizeOfNewColumns As Long)
    Local ColumnCount As Long   
    ColumnCount=SendMessage(hWndControl, %EG_GETMAXCOLUMNS, 0, 0)
    If columncount <1 Then
        columncount=1
    End If
   
   
    If newcolumncount > columncount Then
        SendMessage(hWndControl, %EG_APPENDCOLUMN,newcolumncount-columncount, SizeOfNewColumns&)

    ElseIf newcolumncount < columncount Then
        SendMessage(hWndControl, %EG_KILLCOLUMN, columncount - newcolumncount, 0)

    End If

End Sub


Sub EG_SetRowCount( ByVal hWndControl As Dword,NewRowCount As Long, SizeOfNewRows As Long)
    Local RowCount As Long
    RowCount = SendMessage(hWndControl, %EG_GETMAXROWS, 0, 0)
    If newrowcount <0 Then
        newrowcount=0
    End If

    If newrowcount >0 Then
       SendMessage(hWndControl, %EG_INTERNALSELECTUD, 1, 1)
       SendMessage(hWndControl, %EG_HIDEROW, %false, 0)

       If newrowcount > rowcount Then
            SendMessage(hWndControl, %EG_APPENDROW, newrowcount - rowcount, SizeOfNewRows&)

       ElseIf newrowcount < rowcount Then
            SendMessage(hWndControl, %EG_KILLROW, rowcount - newrowcount, 0)
       
       End If
   
    Else
        SendMessage(hWndControl, %EG_KILLROW, rowcount-1 , 0)         
        SendMessage(hWndControl, %EG_INTERNALSELECTUD, 1, 1)
        SendMessage(hWndControl, %EG_HIDEROW, %TRUE, 0)
   
    End If
   
    SendMessage(hWndControl, %EG_REFRESHALL, 0, 0)
   
End Sub

Sub EG_RemoveAllRows( ByVal hWndControl As Dword)
    Local RowCount As Long

    RowCount = SendMessage(hWndControl, %EG_GETMAXROWS, 0, 0)

    If  rowcount >0 Then
       SendMessage(hWndControl, %EG_KILLROW, rowcount-1 , 0)         
       SendMessage(hWndControl, %EG_INTERNALSELECTUD, 1, 1)
       SendMessage(hWndControl, %EG_HIDEROW, %TRUE, 0)

    End If


End Sub

iniSoft System Technology Limited
Lenovo ThinkPad SL410 4GB Ram,
Windows XP SP3 / PBWin 10 & FireFly 3.51

Michael Shillito

Roy

I'm just curious as to why you would want to display a grid with no rows. Surely for appearances sake you would
display sufficient blank rows to at least fill the size of the grid

Roy Chan

I am not use the Egrid32 as a spreadsheet. I want to load a database table into the Egrid32. Each row represents a record. If the table is empty, I need to remove all rows from the Egrid32. So the user can understand there is no any record inside the database table. I used to use the MSGlexgrid in VB6 as a browse grid.
iniSoft System Technology Limited
Lenovo ThinkPad SL410 4GB Ram,
Windows XP SP3 / PBWin 10 & FireFly 3.51

Brian Chirgwin

This is on the list of changes.
Allow 0 rows / columns.

As well as %EG_SetMaxRows/Columns similar to %EG_GETMaxRows/Columns

Brian Chirgwin
www.egridpro.com

Roy Chan

Brain,

When will the new version release ? I am using version 3.57.01 Demo which is embedded in the FireFly 3.5.
iniSoft System Technology Limited
Lenovo ThinkPad SL410 4GB Ram,
Windows XP SP3 / PBWin 10 & FireFly 3.51

Marc van Cauwenberghe

Hi Roy,
should keep an eye on the egrid forum. Brian said he hoped to have something by the end this year.

Regards,
Marc