VC MSFLEXGrid Basic use

2022-12-20   ES  

Original Source:

1. Bind member variables to the FlexGrid control: m_flexgrid.

2. Set the number of ranks
              m_FlexGrid.SetCols(4);                 // Set the number of columns
              m_FlexGrid.SetRows(6);                // Set the number of rows

3. Set the number of fixed rows and the number of fixed columns
              m_FlexGrid.SetFixedRows(1);        // Set the number of fixed rows to 1 line
              m_FlexGrid.SetFixedCols(0);         // Set the fixed column number 0 column

4. Set the row width and height
             m_FlexGrid.SetColWidth(1,1500);       // Set the column width of the column number 1 to 1500
             m_FlexGrid.SetRowHeight(2,300);      // Set the row height of 300 to 300

5. Set text alignment method
             m_FlexGrid.SetColAlignment(1,4);       // Set the text of text with a column number 1


   parameter corresponds to the description:
             0  Unit content on the top left.
             1  Unit content in the middle. The default setting value of the string.
             2  Unit content at the bottom of the contents of the contents.
             3  Unit content is centered.

The content of the
             4  unit is in the middle.
             5  Unit content at the bottom of the content.
             6  Unit content on the top right.
             7  Unit content in the middle of the right. Digital default settings value.
             8  Unit content bottom right.
              9  Unit content is generally aligned. Align in the middle of the string and align the middle and right in the middle of the value.

6. Set the surface and cell content
     m_FlexGrid.SetTextArray(0,”Head1″);                // Set the head (column 1) content as “head1”
     m_FlexGrid.SetTextMatrix(1,1,”Text”);               // Set cell (line number 1 column number 1) content is “text”

7. Add one line
        m_FlexGrid.AddItem(“AddString”,(COleVariant)(3L));          // Add a line at a position with a line number 3

8. Merge unit grid
                    m_flexgrid.settextMatrix (5, i, “total”);      // Set the contents of the line number 5 and the column number from 0 to 4 to the same “total”
             m_FlexGrid.SetMergeCells(2);                          // Set the cell merger method (hereinafter)
             m_FlexGrid.SetMergeRow(5,TRUE);                // Set the line to be merged

The parameter values of

     setmergecells function are as follows:
             0: flexMergeNever                             The default option is not merged
             1: flexMergeFree                               Irregular mergers
             2: flexMergeRestrictRows                  Line merging
             3: flexMergeRestrictColumns             column merger
             4: flexMergeRestrictBoth                    line, the merger of the list

    Note that only the same content of the cell can be performed.

9. Make editable FlexGrid control

   Place an EDIT control, bind the member variables M_Edit, and set the initial state to be invisible.

   CLICK event in response to the FlexGrid control:

              void CBlackBKDlg::OnClickMsflexgrid()

                     long lCol=m_FlexGrid.GetColSel();        // Get the line number of the click
                     long lRow=m_FlexGrid.GetRowSel();     // Get the column number of the click
                     if(lRow>m_FlexGrid.GetRows() || lRow==0)             // Determine whether the click is valid

                      CRect rect;
                     m_FlexGrid.GetWindowRect(&rect);                // Get the window rectangle of the FlexGrid control
                     ScreenToClient(&rect);                                   // Converted to the client area rectangle
                      CDC* pDC=GetDC();
                     // The length of the function of the function of the MSFLEXGRID control function is “TWIPS”, which needs to be converted into pixels, 1440 ti = 1 inch inch
                     // The conversion ratio of calculating pixels and tats
                       int nTwipsPerDotX=1440/pDC->GetDeviceCaps(LOGPIXELSX);
                     int nTwipsPerDotY=1440/pDC->GetDeviceCaps(LOGPIXELSY);
                     // Calculate the coordinates of the upper left corner of the selected grid (unit)

Random Posts

POJ 2513 Question Report

IOS SDK Detailed UITABBAR (DEMO of Sina Weibo)

Ubuntu Install the Java JDK environment

CSV file read and process The characteristics of

Set up TensorFlow-CPU on win10