<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    大鳥的學習樂園
    路漫漫其修遠兮,吾將上下而求索
    posts - 26,comments - 27,trackbacks - 0

    >> 將文本賦值給MsFlexGrid的單元格
    MsFlexGrid.TextMatrix(3,1)=”Hello”

    >> 在MsFlexGrid控件單元格中插入背景圖形
    Set MsFlexGrid.CellPicture=LoadPicture(“C:\temp\1.bmp”)

    >>選中某個單元
    MsFlexGrid.Row=1
    MsFlexGrid.Col=1

    >>用粗體格式化當前選中單元
    MsFlexGrid.CellFontBold=True

    >> 添加新的一行
    使用AddItem方法,用Tab字符分開不同單元格的內容

    dim row as string
    row=”AAA”&vbtab&”bbb”
    MsFlexFrid1.addItem row


    >>怎樣來實現MSFlexGrid控件單數行背景為白色,雙數的行背景為藍色?
        Dim i As Integer
        With MSFlexGrid1
             .AllowBigSelection = True    ’ 設置網格樣式
             .FillStyle = flexFillRepeat
             For i = 0 To .Rows - 1
                 .Row = i: .Col = .FixedCols
                 .ColSel = .Cols() - .FixedCols - 1
                 If i Mod 2 = 0 Then
                    .CellBackColor = &HC0C0C0    ’ 淺灰
                 Else
                    .CellBackColor = vbBlue ’ 蘭色
                 End If
             Next i
         End With

    >> MSFlexGrid控件如何移到最后一行
    MSFlexGrid1.TopRow = MSFlexGrid1.Rows – 1

    >>如何判斷msflexgrid有無滾動條
    Declare Function GetScrollRange Lib "user32" (ByVal hWnd As Long, ByVal nBar As Long, lpMinPos As Long, lpMaxPos As Long) As Long

    Public Const SB_HORZ = &H0
    Public Const SB_VERT = &H1

    Public Function VsScroll(MshGrid As MSHFlexGrid) As Boolean           ’判斷水平滾動條的可見性
    Dim i As Long
    VsScroll = False
    i = GetScrollRange(MshGrid.hWnd, SB_HORZ, lpMinPos, lpMaxPos)
    If lpMaxPos <> lpMinPos Then VsScroll = True
    End Function

    Public Function HeScroll(MshGrid As MSHFlexGrid) As Boolean           ’判斷垂直滾動條的可見性
    Dim i As Long
    HeScroll = False
    i = GetScrollRange(MshGrid.hWnd, SB_VERT, lpMinPos, lpMaxPos)
    If lpMaxPos <> lpMinPos Then HeScroll = True
    End Function

    >>程序運行時,想動態增加MSFlexgrid的列數
    在第2列后插入一列:

    Private Sub Form_Load()
    Me.MSHFlexGrid1.Cols = 5
    MSHFlexGrid1.Rows = 2
    For i = 0 To Me.MSHFlexGrid1.Cols - 1
    Me.MSHFlexGrid1.TextMatrix(0, i) = i
    Me.MSHFlexGrid1.TextMatrix(1, i) = i
    Next
    End Sub

    Private Sub Command1_Click()
    Me.MSHFlexGrid1.Cols = Me.MSHFlexGrid1.Cols + 1
    Me.MSHFlexGrid1.ColPosition(5) = 3
    End Sub

    >> MSFlexGrid中的對齊功能的使用
    設置MSFlexGrid1.ColAlignment(index)=n


    >>得到MSFlexGrid控件中當前選中的一行
    msflexgrid1.rowsel就是當前選中行

    >> 如何通過代碼調節列寬度
    msflexgrid1.colwidth(i)=4000
    增加 MsFlexGrid 的編輯功能

    概述
    MsFlexGrid 控件沒有提供文本編輯的功能,下面的例子演示了如何利用一個TextBox 實現編輯當前網格的功能。

    在按下一個鍵后, 就把TextBox 移動到當前的位置, 并激活。 在鍵入回車或移動到其他網格時, 就把TextBox 中的內容放到網格中。

    實現步驟
    1 打開 VB5, 開啟一個新的工程。

    2 在菜單“工程” 中選擇 “部件”, 在列表中選中 “Microsoft FlexGrid Control ..”

    3 放一個 MsFlexGrid 控件和一個TextBox 控件(Text1)到 Form1。 修改MsFlexGrid 控件的名稱為 Grid1, 設置Grid1 的行,列 為 4, 固定行,列為 0。 設置 Text1 的 Visiable 為 False, BorderStyle 為 None(0)。

    4 在Form1 的代碼中增加聲明:

    Const ASC_ENTER = 13 '回車
    Dim gRow As Integer
    Dim gCol As Integer

    5 增加代碼到 Grid_KeyPress 過程:

    Private Sub Grid1_KeyPress(KeyAscii As Integer)
    ' Move the text box to the current grid cell:
    Text1.Top = Grid1.CellTop + Grid1.Top
    Text1.Left = Grid1.CellLeft + Grid1.Left
    ' Save the position of the grids Row and Col for later:
    gRow = Grid1.Row
    gCol = Grid1.Col
    ' Make text box same size as current grid cell:
    Text1.Width = Grid1.CellWidth - 2 * Screen.TwipsPerPixelX
    Text1.Height = Grid1.CellHeight - 2 * Screen.TwipsPerPixelY
    ' Transfer the grid cell text:
    Text1.Text = Grid1.Text
    ' Show the text box:
    Text1.Visible = True
    Text1.ZOrder 0 ' 把 Text1 放到最前面!
    Text1.SetFocus
    ' Redirect this KeyPress event to the text box:
    If KeyAscii <> ASC_ENTER Then
    SendKeys Chr$(KeyAscii)
    End If
    End Sub

    6 增加代碼到 Text1_KeyPress 過程:

    Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = ASC_ENTER Then
    Grid1.SetFocus ' Set focus back to grid, see Text_LostFocus.
    KeyAscii = 0 ' Ignore this KeyPress.
    End If
    End Sub

    7 增加代碼到 Text1_LostFocus 過程:

    Private Sub Text1_LostFocus()
    Dim tmpRow As Integer
    Dim tmpCol As Integer
    ' Save current settings of Grid Row and col. This is needed only if
    ' the focus is set somewhere else in the Grid.
    tmpRow = Grid1.Row
    tmpCol = Grid1.Col
    ' Set Row and Col back to what they were before Text1_LostFocus:
    Grid1.Row = gRow
    Grid1.Col = gCol
    Grid1.Text = Text1.Text ' Transfer text back to grid.
    Text1.SelStart = 0 ' Return caret to beginning.
    Text1.Visible = False ' Disable text box.
    ' Return row and Col contents:
    Grid1.Row = tmpRow
    Grid1.Col = tmpCol
    End Sub

    posted on 2008-11-26 07:23 大鳥 閱讀(2159) 評論(1)  編輯  收藏

    FeedBack:
    # re: VB中MsFlexGrid控件的使用細則
    2010-03-08 16:22 | kinkal
    參考下,謝謝!  回復  更多評論
      

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 高h视频在线免费观看| 韩国免费三片在线视频| 午夜成人无码福利免费视频| 亚洲人成电影青青在线播放| 亚洲色婷婷六月亚洲婷婷6月| 国产免费AV片无码永久免费| 两性刺激生活片免费视频| 99re在线这里只有精品免费| 伊人久久大香线蕉免费视频| 特黄特色的大片观看免费视频| 亚洲欧美日韩中文字幕在线一区| 亚洲熟妇av一区| 色拍自拍亚洲综合图区| 无码乱人伦一区二区亚洲| 亚洲性猛交XXXX| 亚洲色偷拍另类无码专区| 美腿丝袜亚洲综合| 国产精品亚洲不卡一区二区三区| 国产成人精品免费视频软件| 午夜男人一级毛片免费| 一二三四免费观看在线电影| 免费可以看黄的视频s色| 99xxoo视频在线永久免费观看| 久草免费手机视频| 久久这里只精品国产免费10| 免费在线看污视频| 久久久99精品免费观看| 在线观看特色大片免费网站 | 国产男女猛烈无遮挡免费网站 | 亚洲日韩国产二区无码| 亚洲乱色熟女一区二区三区蜜臀| 亚洲一日韩欧美中文字幕在线| 在线a亚洲老鸭窝天堂av高清| 亚洲黄页网在线观看| 亚洲欧美成人av在线观看| 亚洲6080yy久久无码产自国产 | 四虎免费久久影院| 亚洲人成网站色在线入口| 亚洲一区二区三区偷拍女厕| 亚洲AV永久纯肉无码精品动漫 | 四虎永久在线精品免费观看视频|