Guidance
指路人
g.yi.org
software / rapidq / examples / GUI / Grid / SuperGrid.bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
     $INCLUDE "RapidQ.inc"

'--- properties --------------
     DEFINT RowCount=7
     DEFINT ColCount=5
     DEFINT DefaultColWidth=64
     DEFINT DefaultRowHeight=24

     DEFINT GridLineWidth=1
     DEFINT GridLineColor=cldgreen
     DEFINT GridWidth=GridLineWidth*(ColCount+1)+DefaultColWidth*ColCount
     DEFINT GridHeight =GridLineWidth*(RowCount+1)+DefaultRowHeight*RowCount
     DEFINT GridColor=&HBAFCE7'cllRed

     DEFINT cellAlignment=taCenter
     DEFINT SelectedBGColor=clyellow

     DEFINT SelCol,SelRow

'!!! --- Merge ---------------------------------
     DEFINT MergeStartCol=1
     DEFINT MergeStartRow=1

     DEFINT MergeCountCol=3
     DEFINT MergeCountRow=3
'-----------------------------------------------

     DECLARE SUB SelectCell ( Sender AS QLABEL)'Col%, Row%, CanSelect%,
'declare sub DrawCell (Sender as QLabel)

     DECLARE SUB CellOnMouseDown (Button%, X%, Y%, Shift%, Sender AS QLABEL)
     DECLARE SUB CellOnMouseUp (Button%, X%, Y%, Shift%,Sender AS QLABEL)

     CREATE Form AS QFORM
      CAPTION = "LabelGrid"
      Width = 420
      Height = 340
      FormStyle = fsStayOnTop
      Center
      CREATE PanelGrid AS QPANEL
       Left =2
       Top = 2
       Width=GridWidth
       Height=GridHeight

       CAPTION = "Panel1"
       TabOrder = 8
       COLOR=GridLineColor
       BevelOuter =bvnone
       BevelInner=bvnone
      END CREATE
     END CREATE

     DIM Labels(RowCount,ColCount) AS QLABEL
     k=0

     FOR i=0 TO  RowCount-1
      FOR j=0 TO  ColCount-1
       Labels(i,j).PARENT=PanelGrid
       Labels(i,j).tag=-k
       Labels(i,j).Autosize=0
       Labels(i,j).Alignment=cellAlignment
       Labels(i,j).left=GridLineWidth*(j+1)+DefaultColWidth*j
       Labels(i,j).top=GridLineWidth*(i+1)+DefaultRowHeight*i
       Labels(i,j).CAPTION=STR$(Labels(i,j).top)
       Labels(i,j).OnClick=SelectCell
       Labels(i,j).COLOR=GridColor
       Labels(i,j).Height=DefaultRowHeight
       Labels(i,j).Width=DefaultColWidth

       IF i>=MergeStartRow  AND i<MergeStartRow+MergeCountRow AND j>=MergeStartCol AND j<MergeStartCol+MergeCountCol THEN
        Labels(i,j).CAPTION="Merged"
        Labels(i,j).visible =0
        Labels(i,j).COLOR=clLBlue
       END IF

       IF i=MergeStartRow AND j=MergeStartRow THEN
        Labels(i,j).Height=GridLineWidth*(MergeCountRow-1)+DefaultRowHeight*MergeCountRow
        Labels(i,j).Width=GridLineWidth*(MergeCountCol-1)+DefaultColWidth*MergeCountCol
        Labels(i,j).COLOR=clred
        Labels(i,j).visible =1
       END IF
       INC k
      NEXT j
     NEXT i

     Form.SHOWMODAL

'**********************************************************************
     SUB CellOnMouseDown (Button%, X%, Y%, Shift%,Sender AS QLABEL)
'Sender.Color=SelectedBGColor
      Sender.CAPTION=STR$(X%)+"\"+STR$(Y%)
     END SUB

'**********************************************************************
     SUB CellOnMouseUp (Button%, X%, Y%, Shift%,Sender AS QLABEL)
'Sender.Color=GridColor
     END SUB

'**********************************************************************
     SUB SelectCell ( Sender AS QLABEL)'Col%, Row%, CanSelect%,
      Labels(SelRow,SelCol).COLOR=GridColor

      FOR i=0 TO  RowCount-1
       FOR j=0 TO  ColCount-1

        IF Sender.tag=Labels(i,j).tag  THEN
         SelCol=j
         SelRow=i
        ELSE
        END IF

       NEXT j
      NEXT i

      Sender.COLOR=SelectedBGColor

     END SUB


掌柜推荐
 
 
¥264.00 ·
 
 
¥810.00 ·
 
 
¥1,480.00 ·
 
 
¥1,370.00 ·
 
 
¥1,290.00 ·
 
 
¥397.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2009-07-25 17:30:04