PlanetSquires Forums

Support Forums => General Board => Topic started by: Roy Chan on November 10, 2011, 06:06:37 AM

Title: Egrid32 - How to set the column count and row count at run time ?
Post by: Roy Chan on November 10, 2011, 06:06:37 AM
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
Title: Re: Egrid32 - How to set the column count and row count at run time ?
Post by: James Padgett on November 10, 2011, 07:36:53 AM
You might ask at   www.egridpro.com  ....


Title: Re: Egrid32 - How to set the column count and row count at run time ?
Post by: Michael Shillito on November 10, 2011, 02:56:16 PM
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


Title: Re: Egrid32 - How to set the column count and row count at run time ?
Post by: Roy Chan on November 11, 2011, 01:40:23 AM
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
Title: Re: Egrid32 - How to set the column count and row count at run time ?
Post by: Brian Chirgwin on November 11, 2011, 10:18:50 PM

Also EG_SetEGridSize(hwnd, columns, rows)


Title: Re: Egrid32 - How to set the column count and row count at run time ?
Post by: Roy Chan on November 12, 2011, 02:28:15 AM
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

Title: Re: Egrid32 - How to set the column count and row count at run time ?
Post by: Michael Shillito on November 12, 2011, 05:31:51 AM
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
Title: Re: Egrid32 - How to set the column count and row count at run time ?
Post by: Roy Chan on November 12, 2011, 10:47:48 AM
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.
Title: Re: Egrid32 - How to set the column count and row count at run time ?
Post by: Brian Chirgwin on November 13, 2011, 01:19:30 AM
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
Title: Re: Egrid32 - How to set the column count and row count at run time ?
Post by: Roy Chan on November 13, 2011, 03:17:56 AM
Brain,

When will the new version release ? I am using version 3.57.01 Demo which is embedded in the FireFly 3.5.
Title: Re: Egrid32 - How to set the column count and row count at run time ?
Post by: Marc van Cauwenberghe on November 13, 2011, 12:11:21 PM
Hi Roy,
should keep an eye on the egrid forum. Brian said he hoped to have something by the end this year.

Regards,
Marc