How do you delete and modify a row in a MSHFlexGrid multiline?

Source: Internet
Author: User

In the computer room fee system, the student basic information maintenance form involves a row that modifies the MSHFlexGrid selection, so how should this be achieved?

Oneself in the beginning of a lot of detours, just start to think that they have achieved, in fact, is not just an accidental phenomenon, I just started this writing:

First time:

The 1th item is selected in the MSHFlexGrid property "SelectionMode", which is then written in the code of the Modify command button:

        Txtsql= "SELECT * from Student_info where cardid= '" & MSHFlexGrid1. SelectionMode & "'"
        Set resi = ExecuteSQL (txtSQL, Msgtext)

At this time, it happened, I thought it could be achieved, but when I click on the second line, it does not appear, and later by the MSHFlexGrid of the property "SelectionMode" selected the 2nd item, then found that is always showing a row, That is, the first line of the place where the mouse is pointing to the blue, and then start looking for information about the properties of MSHFlexGrid, where the MSHFlexGrid attribute "SelectionMode" the first "0-flexselectionfree" is free to choose; the second "1-selectionbyrow" is based on the line, that's the line number, not the name of one of the fields, so my mistakes can be imagined, but if your first line of cards is exactly 1, then there's my phenomenon, which is exactly what you want, But we should not have such a lucky mentality; the third "2-flexselectioncolnm" of course is according to the display of the column, and the card number is unable to correspond with your one by one, the only one is 2nd, so no matter how you choose, it always selects the second line.

So I started looking for information to see exactly what to do:

Option Explicit
Dim SelectRow as Integer
Private Sub mshflexgrid1_mousedown (Button As Integer, Shift as Integer, x as single, y as single) with
        Mshflexgrid1
  . Row =. Mouserow
                        SelectRow =. Row
                        . Col = 0
                        . Colsel =. Cols-1 End With
        
End Sub
Private Sub mshflexgrid1_mouseup (Button As Integer, Shift as Integer, x as single, y as single) with
        MSHFlexGrid1
                        . Rowsel = SelectRow
                        . Colsel =. Cols-1 End and end

Sub


Then select the selected row in the Modify command button to modify it:

Private Sub Command1_Click ()
    Dim txtsql As String
    Dim Msgtext As String
    Dim resi as ADODB. Recordset
    Dim i As Integer
    Dim j As Integer
    
    ' select MSHFlexGrid1 row and modify it
    txtsql = ' SELECT * from Student_inf o where cardid= ' "& Trim (Mshflexgrid1.textmatrix (mshflexgrid1.row, 0)) &" "
    Set Resi = ExecuteSQL (txtSQL, MS Gtext)
    frmsinf.text1 (0) = Resi.fields (1)
    frmsinf.text1 (2) = Resi.fields (6)
    frmsinf.text1 (1) = Resi.fields (2)
    frmsinf.text1 (6) = Resi.fields (0)
    Frmsinf.combo1 = Resi.fields (3)
    frmsinf.text1 (7) = Resi.fields (7)
    frmsinf.text1 (3) = Resi.fields (4)
    frmsinf.text1 (8) = Resi.fields (8)
    Frmsinf.text1 (4) = Resi.fields (5)
    frmsinf.text1 (7) = Resi.fields (7)
    Frmsinf.text1 (9) = Resi.fields (one)
    frmsinf.show
    setparent Frmsinf.hwnd, Frmmain.hwnd
    
End Sub


At the same time to the MSHFlexGrid selected row to delete the same reason ~

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.