Common vsflexgrid Functions

Source: Internet
Author: User

Vsflexgrid is an ActiveX control of componentone. It is functionally compatible with the mshflexgrid control of MS, that is, the attributes and methods of mshflexgrid are also available, only a few attribute names are slightly different. programs written using mshflexgrid can be converted with only a small adjustment. However, compared with mshflexgrid, vsflexgrid provides many functions, its Attributes and events are rich and can be flexibly controlled and quickly encoded. The following describes some common and practical functions:

I. Batch Data Operations

L use cell attributes to batch access data

For example, to clear the text of a region or set the font of a region, you do not need to process it cyclically. You only need one statement to complete the process, for example:

Vsflexgrid. Cell (flexcptext,) = "" 'Set ()-() text in the cell area is empty

Vsflexgrid. Cell (flexcpfontbold,) = true' set ()-() the font of the cell area is in bold.

You can also set cell alignment, images, and colors.

 

Statement: strtext = vsflexgrid. Cell (flexcptext)

Returns a string of vbtab-separated columns and vbcr-separated rows. Of course, values can be assigned in turn, so that different values can be assigned to each cell in the region.

L use-1 to process all rows and columns

Rowheight (-1) = 100' sets the height of all rows to 300 twip, which can be similar to the following attributes:

Rowhidden, colwidth, colhidden, colalignment, etc.

 

2. Massive Data Storage

Vsflexgrid can store data in the following places: celltext, celldata, coldata, and rowdata.

Except for the string type, celltext is of the variant type. That is to say, you can store any type of data in tables, such as date, type ), collection, array, recordset, and various objects are very useful for programs with a large amount of associated data.

 

Note: vsflexgrid. Cell (flexcptext, 1, 1) = rsdata! Name actually stores An ADO. Field object. You should use CSTR (rsdata! Name) specifies the type.

 

Iii. editing features

Vsflexgrid cells can be edited in the following ways:

L text box: As long as editable is set to editable, each cell is the textbox editing style by default.

L drop-down box:

You can edit a unit in the VB. ComboBox style by setting the combolist attribute of the current cell or the colcombolist attribute of the specified column. Multiple columns can be displayed in the drop-down list, for example:

Vsflexgrid. combolist = _

"| #100*1; Zhang San" & vbtab & "male" & vbtab & "28 years old "&_

"| #101; Li Si" & vbtab & "male" & vbtab & "29 years old "&_

"| #102; Wang Wu" & vbtab & "male" & vbtab & "30 years old"

"|" Refers to data of each row, while vbtab refers to data of each column. 1st "|" indicates that data can be input in the drop-down box. "#" is followed by itemdata of each row, "* 1" after the first itemdata indicates that data in the 1st column is displayed in ComboBox after selection.

 

L check box:

Set coldatatype = flexdtboolean for the specified column, or specify the cellchecked attribute of the current cell.

L select button:

Set the combolist attribute of the current cell or the colcombolist attribute of the specified column "..." You can use it with the cellbuttonclick event.

 

Iv. interface features

1) Border

In addition to table lines, vsflexgrid can also set border lines in the unit format, including color, width, and whether or not, similar to excel:

Vsflexgrid. cellborder color as ole_color, left as integer, top as integer, right as integer, bottom as integer, vertical as integer, horizontal as integer

 

2) Automatic Row Height and column width

The autosize method enables adaptive adjustment of the column width or row height based on the content of cells.

You can also double-click the header to adjust the column width.

 

3) tree indent (treelist)

By setting the issubtotal and rowoutlinelevel attributes of table rows, you can achieve a tree-style indent hierarchical style, so that vsflexgrid can combine Treeview and listview.

 

4) Self-Painting

By setting the ownerdraw attribute, you can perform self-painting on the cell content, mainly in combination with the drawcell event:

Drawcell (byval HDC as long, byval row as long, byval Col as long, byval left as long, byval top as long, byval right as long, byval bottom as long, done as Boolean)

 

5) Background

You can set a background image for vsflexgrid. The background image is transparent to the unit format, and you can set the alignment and Paster attributes.

 

6) Sort columns and drag rows and columns

Setting the vsflexgrid. assumerbar attribute allows you to click the column header to sort the column data, or drag the cursor to change the sequence of the column and row, similar to Windows Resource Manager.

7) Freeze the row and column

In addition to the fixed row and column headers, you can also use vsflexgrid like excel. frozencols/frozenrows sets the frozen row and column to have the same effect as the fixed row and column when the frozen row and column are rolling, but the cursor can enter the cells within the frozen row and column range.

 

5. Rich Event Control:

Vsflexgrid has more than 50 events. These events are mainly used for editing and interface control. during use, it is often found that an event is particularly useful. Therefore, make full use of these events, you can easily implement many functions. The following lists the supported events and their corresponding lists. Bold is commonly used and its functions can be seen from the definition. A detailed Event Description, you can view help.

L aftercollapse (byval row as long, byval state as integer)

L afterdatarefresh ()

LAfteredit(Byval row as long, byval Col as long)

L aftermovecolumn (byval Col as long, position as long)

L aftermoverow (byval row as long, position as long)

LAfterrowcolchange(Byval oldrow as long, byval oldcol as long, byval newrow as long, byval newcol as long)

L afterscroll (byval oldtoprow as long, byval oldleftcol as long, byval newtoprow as long, byval newleftcol as long)

L afterselchange (byval oldrowsel as long, byval oldcolsel as long, byval newrowsel as long, byval newcolsel as long)

L aftersort (byval Col as long, order as integer)

L afteruserfreeze ()

L afteruserresize (byval row as long, byval Col as long)

L beforecollapse (byval row as long, byval state as integer, cancel as Boolean)

L beforedatarefresh (cancel as Boolean)

L beforeedit (byval row as long, byval Col as long, cancel as Boolean)

L beforemousedown (byval button as integer, byval shift as integer, byval X as single, byval y as single, cancel as Boolean)

LBeforemovecolumn(Byval Col as long, position as long)

L beforemoverow (byval row as long, position as long)

L beforepagebreak (byval row as long, breakok as Boolean)

LBeforerowcolchange(Byval oldrow as long, byval oldcol as long, byval newrow as long, byval newcol as long, cancel as Boolean)

LBeforescroll(Byval oldtoprow as long, byval oldleftcol as long, byval newtoprow as long, byval newleftcol as long, cancel as Boolean)

L beforescrolltip (byval row as long)

L beforeselchange (byval oldrowsel as long, byval oldcolsel as long, byval newrowsel as long, byval newcolsel as long, cancel as Boolean)

LBeforesort(Byval Col as long, order as integer)

LBeforeuserresize(Byval row as long, byval Col as long, cancel as Boolean)

LCellbuttonclick(Byval row as long, byval Col as long)

LCellchanged(Byval row as long, byval Col as long)

L changeedit ()

L click ()

L combocloseup (byval row as long, byval Col as long, finishedit as Boolean)

L combodropdown (byval row as long, byval Col as long)

L compare (byval row1 as long, byval row2 as long, CMP as integer)

L dblclick ()

L dragdrop (source as control, X as single, y as Single)

L dragover (source as control, X as single, y as single, State as integer)

LDrawcell(Byval HDC as long, byval row as long, byval Col as long, byval left as long, byval top as long, byval right as long, byval bottom as long, done as Boolean)

L endautosearch ()

L entercell ()

L error (byval errorcode as long, showmsgbox as Boolean)

L filterdata (byval row as long, byval Col as long, value as string, byval savingtodb as Boolean, wantthiscol as Boolean)

L getheaderrow (byval row as long, headerrow as long)

L gotfocus ()

L keydown (keycode as integer, shift as integer)

L keydownedit (byval row as long, byval Col as long, keycode as integer, byval shift as integer)

L keypress (keyascii as integer)

LKeypressedit(Byval row as long, byval Col as long, keyascii as integer)

L keyup (keycode as integer, shift as integer)

L keyupedit (byval row as long, byval Col as long, keycode as integer, byval shift as integer)

L leavecell ()

L lostfocus ()

L mousedown (button as integer, shift as integer, X as single, y as Single)

L mousemove (button as integer, shift as integer, X as single, y as Single)

L mouseup (button as integer, shift as integer, X as single, y as Single)

L olecompletedrag (effect as long)

L oledragdrop (data as vsflex8ctl. vsdataobject, effect as long, byval button as integer, byval shift as integer, byval X as single, byval y as Single)

L oledragover (data as vsflex8ctl. vsdataobject, effect as long, byval button as integer, byval shift as integer, byval X as single, byval y as single, State as integer)

L olegivefeedback (effect as long, defaultcursors as Boolean)

L olesetcustomdataobject (customdataobject as variant)

L olesetdata (data as vsflex8ctl. vsdataobject, dataformat as integer)

L olestartdrag (data as vsflex8ctl. vsdataobject, allowedeffects as long)

L rowcolchange ()

L selchange ()

L setupeditstyle (byval row as long, byval Col as long, byval iscombo as Boolean, style as long, styleex as long)

L setupeditwindow (byval row as long, byval Col as long, byval editwindow as long, byval iscombo as Boolean)

L startautosearch ()

LStartedit(Byval row as long, byval Col as long, cancel as Boolean)

L startpage (byval HDC as long, byval page as long, cancel as Boolean)

L validate (cancel as Boolean)

LValidateedit(Byval row as long, byval Col as long, cancel as Boolean)

 

Vi. Additional functions:

1) property page:

On the attribute page of vsflexgrid, you can design the format and content of the table, which saves some code (the processed content of this attribute page is saved in the frx file of the form ).

 

2) import/export:

You can use the loadgrid/savegrid method to import and export table content. There are several formats for import and export:

L its own binary format.

L text files with certain delimiters.

L excel97 format (no need to install Excel, fast, but some attributes are not supported ).

3) print

The printgrid method can be used to print and output vsflexgrid according to the current format and data. However, this function is relatively simple, such as previewing and setting the header and footer. (The combination of vsview and vsflexgrid, another control of componentone, can implement powerful printing functions)

 

As a control with a size of more than 600 K (vsflexgrid. OCX), the function is really very good, and it has been used in a lot in zlhis, the above just briefly lists some of its functions, for more detailed functions, you can run its demo for demonstration, or view its help files, all of which are more detailed.

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.