初始化 Egrid 的欄數,列數,大小, 欄目名稱等
Sub FRMBROWSEDATA_InitGrid
SendMessage (HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_FULLLINEMODE , %TRUE, 0)
SendMessage(HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_SETSELSHOWSTATE, %TRUE, 0)
SendMessage(HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_SHOWCOLHEADER, %true, 0)
SendMessage(HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_SHOWROWHEADER, %FALSE, 0)
SendMessage(HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_SETDEFAULTROWHEIGHT, 25, 0)
SendMessage(HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_SETDEFAULTROWHEIGHT, 26, 0)
SendMessage(HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_SETEDITLOCK, %TRUE, 0)
EG_SetColumnCount HWND_FRMBROWSEDATA_EGRDBROWSE,5,30
EG_RemoveAllRows HWND_FRMBROWSEDATA_EGRDBROWSE
SendMessage(HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_SETCOLUMNSIZE, %cntautoid, 80 )
EG_SetColumnHeaderCaption(HWND_FRMBROWSEDATA_EGRDBROWSE ,%cntautoid,"Auto ID")
EG_SetColumnBothAlignment ( HWND_FRMBROWSEDATA_EGRDBROWSE ,%cntautoid, %TA_center,%TA_Center)
SendMessage(HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_SETCOLUMNSIZE, %cntDatatype, 200 )
EG_SetColumnHeaderCaption(HWND_FRMBROWSEDATA_EGRDBROWSE ,%cntdatatype,"Data Type")
EG_SetColumnBothAlignment ( HWND_FRMBROWSEDATA_EGRDBROWSE ,%cntdatatype, %TA_left,%TA_center)
SendMessage(HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_SETCOLUMNSIZE, %cntcontents, 530 )
EG_SetColumnHeaderCaption(HWND_FRMBROWSEDATA_EGRDBROWSE ,%cntcontents,"Contents")
EG_SetColumnBothAlignment ( HWND_FRMBROWSEDATA_EGRDBROWSE ,%cntcontents, %TA_left,%TA_center)
SendMessage(HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_SETCOLUMNSIZE, %cntlastupdate, 160 )
EG_SetColumnBothAlignment (HWND_FRMBROWSEDATA_EGRDBROWSE ,%cntlastupdate,%TA_center,%TA_Center)
EG_SetColumnHeaderCaption(HWND_FRMBROWSEDATA_EGRDBROWSE ,%cntlastupdate,"Last Update")
EG_SetColumnHeaderVerticalAlignment( HWND_FRMBROWSEDATA_EGRDBROWSE,%TA_Center)
EG_SetColumnHeaderHorizonAlignment( HWND_FRMBROWSEDATA_EGRDBROWSE,%TA_CENTER)
EG_SetColumnVisible(HWND_FRMBROWSEDATA_EGRDBROWSE,%cntDataTypeID,%false)
End Sub
填入資料表至表格內
Sub FRMBROWSEDATA_FillegrdBrowse
Dim tmpSQL As String
Dim tmpData As String
Dim lngErrNum As Long
tmpsql="select a.*,b.qrdatadesc from (qrdatarecord a left join qrdatatype b on a.datatype=b.autoid) order by autoid desc"
slSel tmpsql
lngErrNum = slGetErrorNumber
If lngErrNum <> 0 Then
MsgBox "Error Number is: " & Str$(lngErrNum), 0, "Error"
Else
Do While slGetRow
tmpdata= slFN("autoid")
tmpdata= tmpdata & $Tab & slFN("qrdatadesc")
tmpdata= tmpdata & $Tab & Trim$(Utf8ToChr$(slFN("contents")))
tmpdata= tmpdata & $Tab & DbltoDateTime(Val( slFN("lastupdate")))
tmpdata= tmpdata & $Tab & slFN("datatype")
EG_AddRowData HWND_FRMBROWSEDATA_EGRDBROWSE,tmpdata
Loop
End If
slCloseSet
End Sub
反白目前的列
Function FRMBROWSEDATA_EGRDBROWSE_EGN_SELECTIONCHANGED (ControlIndex As Dword, HwndForm As Dword, hEGrid As Long, wParam As Dword, lParam As Long) As Long
Local EGN As EgridNotify Ptr
Local nCols As Long
EGN = lParam
nCols = SendMessage (HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_GetMaxColumns, 0, 0)
@EGN.Selec.SX1 = 1
@EGN.Selec.SX2 = nCols
End Function
按欄目名稱排序當前欄位
Function FRMBROWSEDATA_EGRDBROWSE_EGN_HEADERLEFTCLICK (ControlIndex As Dword, HwndForm As Dword, hEGrid As Long, wParam As Dword, lParam As Long) As Long
Local EGN As EgridNotify Ptr
Local tmpRows As Long
EGN = lParam
tmprows = SendMessage(HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_GETMAXROWS, 0, 0)
SendMessage(HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_INTERNALSELECTUD, 1,tmprows)
SendMessage(HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_SORTCOLUMN, @EGN.CELL.X, %EG_SORTTEXT Or %EG_SHOWDIRECTION Or %EG_TOGGLE)
SendMessage (HWND_FRMBROWSEDATA_EGRDBROWSE, %EG_REFRESHALL, 0, 0)
'ztrace Str$(tmprows)
End Function