你想使MSFLEXGRID控制項可編輯嗎

來源:互聯網
上載者:User

在MSFLEXGRID控制項中每一個CELL格的內容是不可以由使用者直接編輯的但是我們可以通過一些小技巧來方便的實現這編輯功能來擴充MSFLEXGRID的應用(在實際應用中這是很常用的功能)。

你只需按下面的做即可輕鬆實現編輯MSFLEXGRID控制項資料的功能

例在表單上放一文字框text1,和一MSFLEXGRID控制項flexgrid1

加入下例代碼

Private Sub Form_Load()
   Text1.Move -10000, -10000, 1, 1
End Sub
Private Sub MSFlexGrid1_EnterCell()
   MSFlexGrid1.CellBackColor = vbBlue
   MSFlexGrid1.CellForeColor = vbWhite
   Text1.Text = MSFlexGrid1.Text
   Text1.SelStart = 0
   Text1.SelLength = Len(Text1.Text)
End Sub
Private Sub MSFlexGrid1_LeaveCell()
   MSFlexGrid1.CellBackColor = vbWhite
   MSFlexGrid1.CellForeColor = vbBlue
End Sub
Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
   Text1.SetFocus
End Sub
Private Sub Text1_Change()
   MSFlexGrid1.Text = Text1.Text
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
   Select Case KeyCode
     Case vbKeyLeft, vbKeyRight, vbKeyUp, vbKeyDown
       KeyCode = 0
   End Select
End Sub

ok,這樣一個可編輯的MSFLEXGRID控制項就完成了,簡單吧!!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.