CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 1999
    Location
    Blue Springs, MO
    Posts
    43

    Undo on an MSFlexGrid

    I have an app that allows users to select items from a ComboBox, click a FlexGrid and the item in the ComboBox apperars in the FlexGrid.

    Works great.

    Users have asked for an Undo feature.

    I've thrown up my hands and yelled "I don't know how to do that!" but they insist.

    Anyone have any pointers on how to implement Undo on the FlexGrid?

    Thanks!


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Undo on an MSFlexGrid

    'Windows API provides an undo function

    'Do the following declares:
    Declare Function SendMessage Lib "User" (ByVal hWnd As _
    Integer, ByVal wMsg As Integer, ByVal wParam As _
    Integer, lParam As Any) As Long

    Global Const WM_USER = &h400
    Global Const EM_UNDO = WM_USER + 23


    'And in your Undo Sub do the following:
    UndoResult = SendMessage(myControl.hWnd, EM_UNDO, 0, 0)
    'UndoResult = -1 indicates an error.

    =========================================================

    'another approach can be done if you memorize the cell where you enter tha last entry and on 'Undo' button set the cell value to ""

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Oct 2001
    Posts
    13

    Re: Undo on an MSFlexGrid


    Try this out ,
    When you click the msflex to enter the new selection from the combo,Before updating the new value to the cell, trap the value of the cell using
    msflex.textmatrix(msflex.row,msflex.col) in a variable say Temp.

    temp=msflex.textmatrix(msflex.row,msflex.col)

    Then on the undo button click assign the

    msflex.textmatrix(msflex.row,msflex.col)=temp

    Let me if this works.


  4. #4
    Join Date
    Oct 2001
    Posts
    13

    Re: Undo on an MSFlexGrid


    Dim temp as string

    private Sub Command1_Click()
    MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, MSFlexGrid1.Col) = temp
    End Sub

    private Sub Form_Load()
    MSFlexGrid1.TextMatrix(1, 1) = "apple"
    End Sub

    private Sub MSFlexGrid1_Click()

    temp = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, MSFlexGrid1.Col)
    MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, MSFlexGrid1.Col) = Combo1.Text
    End Sub



    Here is an example using a combo1 msflexigrid1 and command1 controls

    create the three controls and paste the code and add a few items to the list property of the combo1.

    PLEASE let me know if you hav any questions




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured