VB6-practical code for table control mshflexgrid

Source: Internet
Author: User

Although data to be displayed in VB6 includes DataGrid, msflexgrid, mshflexgrid, vsflexgrid, and true dbgrid7.0, the most frequently used data in my work is mshflexgrid, below I will often share some tips and method code for using this control, so that you can use it once you get it.

 

1. Use the formatstring attribute of mshflexgrid to set the row title and Column Title dim stitle as string stitle = "<name | <address | <telephone | <Social Security>" stitle = stitle + "; | Robert | Jimmy | Bonzo | John Paul "mshflexgrid. formatstring = stitle dim stitle as string 'column title' set data source set msh_data.datasource = allrs msh_data.refresh '// you cannot click to point to a row. // If msh_data.rows> 1 then rows = 0 rows = 1 end if with msh_data 'fill in the number of records on the left. textmatrix (0, 0) = "no." dim I as long for I =. fixedrows. rows -. fixedrows. textmatrix (I, 0) = I next I. rowheight (0) = 600 'set the height of the first line, that is, the title bar', and click Select the entire line. focusrect = flexfocusnone. selectionmode = flexselectionbyrow 'msh _ data. backcolorsel = vbyellow: the first column is fixed. Otherwise, the next column is automatically moved to the last column. col = 1. formatstring = stitle 'sets the column title content. colwidth (0) = 0. colwidth (1) = 600 end with 'refresh and then select the first line msh_data.row = Hangzhou msh_data.col = 0 Shanghai = Hangzhou-1 'to refresh and then select the last line msflexgrid1.row = Hangzhou-Hangzhou msflexgrid1.col. = 0 msflexgrid1.colsel = msflexgrid1.cols-1

'Prohibit mshflexgrid from selecting multiple rows of records

'Method 1
Private sub mshflexgrid1_mousemove (button as integer, shift as integer, X as single, y as Single)
If mshflexgrid1.rowsel <> mshflexgrid1.row then mshflexgrid1.rowsel = mshflexgrid1.row
End sub

'Method 2

Private sub msh_data_mousedown (button as integer, shift as integer, X as single, y as Single)

If msh_data.mouserow = 0 Then exit sub

With msh_data
. Row =. mouserow
Currentrow =. Row
. Col = 0' if it is 0, multiple rows can be selected.
. Colsel =. Cols-1
End

End sub

Private sub msh_data_mouseup (button as integer, shift as integer, X as single, y as Single)

If msh_data.mouserow = 0 Then exit sub

With msh_data
. Rowsel = currentrow
. Colsel =. Cols-1
End

End sub

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.