發問時間: 電腦與網際網路程式設計 · 1 0 年前

如何刪除MsFlexGrid中的某一列

要如何使用TextBox輸入某一行的名稱

然後再用CommandButton執行來刪除那一列

刪除完後~所有資料都往上移~讓MsFlexGrid沒有空白的列

麻煩vb高手幫忙解答一下~感謝

已更新項目:

我知道RemoveItem是刪除~不過我想要知道完整的程式碼

麻煩一下~感謝喔!!

1 個解答

評分
  • Wow
    Lv 6
    1 0 年前
    最佳解答

    可以使用

    1) 新增 AddItem

    2) 刪除 RemoveItem

    2007-06-26 17:17:30 補充:

    Private Sub cmdDeleteRow_Click()

    Dim intResponse As Integer

    'can't delete if no Tasks

    If grdSupTasks.Rows = 1 Then

     Exit Sub

    End If

    2007-06-26 17:17:57 補充:

    'Ask for confirmation; delete selected task from list

    intResponse = MsgBox("Please confirm that you wish to " _

             & "delete Row " & grdSupTasks.Row _

             & " from this Report", vbYesNo _

             + vbDefaultButton2, "Confirm Delete")

    2007-06-26 17:18:25 補充:

    If intResponse = vbYes Then

     If grdSupTasks.Rows = 2 Then

       grdSupTasks.Rows = 1 'special method to delete the only Task

       Exit Sub

     Else

       grdSupTasks.RemoveItem (grdSupTasks.Row)

     End If

    End If

    2007-06-26 17:18:43 補充:

    'Renumber items moved up by this delete

    Dim i As Integer

    For i = grdSupTasks.Row To grdSupTasks.Rows - 1

     grdSupTasks.TextMatrix(i, 0) = i

    Next

    End Sub

還有問題?馬上發問,尋求解答。