如:现在有3列 
第一列数量,第二列单价,第三列总金额
计算功式:总金额=单价*单价
我现在把这几列的位置换了后,怎样还能使计算正确

解决方案 »

  1.   

    使用列的索引
    vsflexgrid.textmatrix(row,vsflexgrid.colindex("金额"))=vsflexgrid.textmatrix(row,vsflexgrid.colindex("单价"))*vsflexgrid.textmatrix(row,vsflexgrid.colindex("数量"))
      

  2.   

    to:AKillGodKillBuddha(神挡杀神 佛挡杀佛) 
    問題已經解決。謝謝了
    再問兩個小問題。這個問題解決了就結貼。
    1。如何按回車跳到下一個框,並先中框中的內容。
    2。當一列設置爲日期時,能不能選擇日期,
      

  3.   

    ‘参考1下
    1、Private Sub VSFlexGrid1_KeyPress(KeyAscii As Integer)
       If KeyAscii = 13 Then
            VSFlexGrid1.Row = VSFlexGrid1.Row + 1
          
       End If
     
    End Sub
      

  4.   

    2。combolist属性设为"..."
    然后在CellButtonClick事件中弹出一个选择时间的窗口
    像你说的那样 我还没有试过 不知道
      

  5.   

    '下面例子演示利用DPTPicker选择时间,在窗体上放一个VSFlexDrid,一个DPTPicker
    Option ExplicitPrivate Sub dtPick_Change()
        
        ' update grid value whenever the data changes
        fg.Text = dtPick.Value
        
    End SubPrivate Sub dtPick_KeyDown(KeyCode As Integer, Shift As Integer)
        
        ' close date picker when user hits escape or return
        Select Case KeyCode
            Case vbKeyEscape
                fg = dtPick.Tag
                dtPick.Visible = False
            Case vbKeyReturn
                dtPick.Visible = False
        End Select
        
    End SubPrivate Sub dtPick_LostFocus()    ' hide date picker when user is done with it
        dtPick.Visible = False
        
    End SubPrivate Sub fg_BeforeScroll(ByVal OldTopRow As Long, ByVal OldLeftCol As Long, ByVal NewTopRow As Long, ByVal NewLeftCol As Long, Cancel As Boolean)    ' don't scroll while editing dates
        If dtPick.Visible Then Cancel = TrueEnd SubPrivate Sub fg_BeforeUserResize(ByVal Row As Long, ByVal Col As Long, Cancel As Boolean)
        
        ' don't resize columns while editing dates
        If dtPick.Visible Then Cancel = TrueEnd SubPrivate Sub fg_StartEdit(ByVal Row As Long, ByVal Col As Long, Cancel As Boolean)    ' if this is a date column, edit it with the date picker control
        If fg.ColDataType(Col) = flexDTDate Then
            
            ' we'll handle the editing ourselves
            Cancel = True
            
            ' position date picker control over cell
            dtPick.Move fg.CellLeft, fg.CellTop, fg.CellWidth, fg.CellHeight
            
            ' initialize value, save original in tag in case user hits escape
            dtPick.Value = fg
            dtPick.Tag = fg
            
            ' show and activate date picker control
            dtPick.Visible = True
            dtPick.SetFocus
            
            ' make it drop down the calendar
            SendKeys "{f4}"
            
        End IfEnd Sub
    Private Sub Form_Load()    ' initialize grid
        fg.Editable = flexEDKbdMouse
        fg.AllowUserResizing = flexResizeBoth
        fg.Cols = 4
        fg.ColWidth(0) = fg.RowHeight(0)
        fg.ColWidth(1) = 2500
        fg.ColWidth(2) = 1500
        fg.ColWidth(3) = 1500
        fg.TextMatrix(0, 1) = "Name"
        fg.TextMatrix(0, 2) = "Born"
        fg.TextMatrix(0, 3) = "Hired"
        fg.ColDataType(2) = flexDTDate
        fg.ColDataType(3) = flexDTDate
        fg.ColFormat(2) = "Medium Date"
        fg.ColFormat(3) = "Medium Date"
        fg.ColComboList(2) = "Dummy" ' just to show the down-arrow
        fg.ColComboList(3) = "Dummy" ' just to show the down-arrow
        fg.RowHeightMin = 280
        
        ' fill up with dummy data
        Dim r%
        For r = 1 To fg.Rows - 1
            fg.TextMatrix(r, 1) = "Employee " & r
            fg.TextMatrix(r, 2) = Now - 20 * 365 - Rnd * 20 * 365
            fg.TextMatrix(r, 3) = Now - Rnd * 10 * 365
        Next
        
    End SubPrivate Sub Form_Resize()    ' resize grid to fill form
        On Error Resume Next
        fg.Move fg.Left, fg.Top, ScaleWidth - 2 * fg.Left, ScaleHeight - fg.Top - fg.LeftEnd Sub