How to calculate grid from top to below vb6 năm 2024

With beautiful VB6, I have some trials to edit something like invoice, I found Data grid not familiar to edit tables, also Flex grid has no method to edit. Now I create my ActiveX control using [MSFlexGrid] control, a hidden text box and a hidden combo box. I give the name [VB6Flexgrid] to my ActiveX. I create a project [prjFlexGrid] to test my control. I write the code under Visual Basic 6. With my ActiveX control, you can:

  • Edit any cell in flex grid
  • Delete any row
  • Delete all rows and begin with one row
  • Add combo box to any column and use more than one
  • Write data to any cell
  • Read data from any cell
  • Read all data from the grid

Background

When using my ActiveX control [VB6Flexgrid], the flex grid begins with one row as Data grid control, then increases rows one by one after editing the previous row. My ActiveX control has some methods and some properties:

Method/Property

Definition

Example

ColWidth[anyCol]`Set column width in [Twip]`VB6Flexgrid1.ColWidth[1] = 1500 `TextMatrix[anyRow, anyCol]`Get or set

Set combo box at any column: VB6Flexgrid1.CellType 3, True VB6Flexgrid1.ComboClear 3 VB6Flexgrid1.ComboAddItem 3, „Visual Studio" ' add item to this combo

0for the cell [row, col]

Set combo box at any column: VB6Flexgrid1.CellType 3, True VB6Flexgrid1.ComboClear 3 VB6Flexgrid1.ComboAddItem 3, „Visual Studio" ' add item to this combo

1

Set combo box at any column: VB6Flexgrid1.CellType 3, True VB6Flexgrid1.ComboClear 3 VB6Flexgrid1.ComboAddItem 3, „Visual Studio" ' add item to this combo

2Let

Set combo box at any column: VB6Flexgrid1.CellType 3, True VB6Flexgrid1.ComboClear 3 VB6Flexgrid1.ComboAddItem 3, „Visual Studio" ' add item to this combo

3include combo box if

Set combo box at any column: VB6Flexgrid1.CellType 3, True VB6Flexgrid1.ComboClear 3 VB6Flexgrid1.ComboAddItem 3, „Visual Studio" ' add item to this combo

4

Set combo box at any column: VB6Flexgrid1.CellType 3, True VB6Flexgrid1.ComboClear 3 VB6Flexgrid1.ComboAddItem 3, „Visual Studio" ' add item to this combo

5

Set combo box at any column: VB6Flexgrid1.CellType 3, True VB6Flexgrid1.ComboClear 3 VB6Flexgrid1.ComboAddItem 3, „Visual Studio" ' add item to this combo

6Clear combo box

Set combo box at any column: VB6Flexgrid1.CellType 3, True VB6Flexgrid1.ComboClear 3 VB6Flexgrid1.ComboAddItem 3, „Visual Studio" ' add item to this combo

7

Set combo box at any column: VB6Flexgrid1.CellType 3, True VB6Flexgrid1.ComboClear 3 VB6Flexgrid1.ComboAddItem 3, „Visual Studio" ' add item to this combo

8Add item to combo box

Set combo box at any column: VB6Flexgrid1.CellType 3, True VB6Flexgrid1.ComboClear 3 VB6Flexgrid1.ComboAddItem 3, „Visual Studio" ' add item to this combo

9

VB6Flexgrid1.TextMatrix[2, 3] = „VB6" ' Read any cell: DimstrCellAs String strCell = VB6Flexgrid1. TextMatrix[3, 2]

0Delete current row

VB6Flexgrid1.TextMatrix[2, 3] = „VB6" ' Read any cell: DimstrCellAs String strCell = VB6Flexgrid1. TextMatrix[3, 2]

1

VB6Flexgrid1.TextMatrix[2, 3] = „VB6" ' Read any cell: DimstrCellAs String strCell = VB6Flexgrid1. TextMatrix[3, 2]

2Clear the grid

VB6Flexgrid1.TextMatrix[2, 3] = „VB6" ' Read any cell: DimstrCellAs String strCell = VB6Flexgrid1. TextMatrix[3, 2]

3

To use my ActiveX [VB6Flexgrid], you must add the file VB6Flexgrid.ocx and MicrosoftFlexGrid control to ‘ToolBox’ as follows:

  • Click ‘ToolBox’, then choose Components.
  • From Components dialog, choose Microsoft FlexGrid Control 6.0.
  • Click ‘Browse’ then choose ‘VB6FlexGrid.ocx’ ActiveX control from where you had saved, then click ‘OK’.

Using the Code

About columns:

VB6Flexgrid1.FixedCols = 0 VB6Flexgrid1.Cols = 5

VB6Flexgrid1.ColWidth[1] = 1500

VB6Flexgrid1.ColAlignmentHeader[1] = flexAlignCenterCenter

    
VB6Flexgrid1.ColAlignment[1] = flexAlignLeftCenter

About combo box:

Set combo box at any column: VB6Flexgrid1.CellType 3, True VB6Flexgrid1.ComboClear 3 VB6Flexgrid1.ComboAddItem 3, „Visual Studio" ' add item to this combo

About cell:

VB6Flexgrid1.TextMatrix[2, 3] = „VB6" ' Read any cell: DimstrCellAs String strCell = VB6Flexgrid1. TextMatrix[3, 2]

You can go back to source files of the project [prjFlexGrid] to read more than the previous examples.

Remarks

When extracting the file VBFlexGrid.zip, you can find the file: ..\VBFlexGrid\ActiveXcontrol\VB6Flexgrid.ocx, find the project to test the ActiveX control in the folder: ..\ VBFlexGrid.

This project has three forms:

  • VB6Flexgrid1.TextMatrix[2, 3] = „VB6" ' Read any cell: DimstrCellAs String strCell = VB6Flexgrid1. TextMatrix[3, 2] 6: To choose language
  • VB6Flexgrid1.TextMatrix[2, 3] = „VB6" ' Read any cell: DimstrCellAs String strCell = VB6Flexgrid1. TextMatrix[3, 2] 7: For English language
  • VB6Flexgrid1.TextMatrix[2, 3] = „VB6" ' Read any cell: DimstrCellAs String strCell = VB6Flexgrid1. TextMatrix[3, 2] 8: For Arabic language

VB6Flexgrid1.TextMatrix[2, 3] = „VB6" ' Read any cell: DimstrCellAs String strCell = VB6Flexgrid1. TextMatrix[3, 2]

9and `MSFlexGrid`0have the same controls:

  • The ActiveX control [`MSFlexGrid`1] adds the file VB6Flexgrid.ocx
  • The button control [`MSFlexGrid`2] to delete one row
  • The button control [`MSFlexGrid`3] to clear the grid
  • The button control [`MSFlexGrid`4] writes data to the first cell
  • The button control [`MSFlexGrid`5] to read the current cell
  • The button control [`MSFlexGrid`6] to copy all data from grid to list box
  • The button control [`MSFlexGrid`7] closes the form
  • The list box control [`MSFlexGrid`8] holds data from grid

Last Words

I hope this article is useful and helps you to create your applications. If you have any ideas or if you find any problems, please tell me. Thanks to CodeProject and thanks to all.

-- Mostafa Kaisoun

This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

How to use MSFlexGrid in VB6?

Add the MSFlexGrid control to your project:.

Go to the Project menu, pick Components..

Scroll down the list of components until you find "Microsoft FlexGrid Control 6.0 [sp3]". Select that checkbox and hit the OK button to add the control to your project..

How to add DataGrid in VB6?

To add the DataGrid control, click on the project on the menu bar and select components to access the dialog box that displays all the available VB6 components, as shown in the diagram below. Select Microsoft DataGrid Control 6.0 by clicking the checkbox beside this item.

What is flex grid control in VB?

MSFlexGrid control in VB is used to create applications that present information in rows and columns.Information is displayed in cells.

How to edit data in DataGrid in VB6 0?

firstly ,Data Grid control and Adodc are not available on toolbox.So add these controls to form for use. Next make the database connectivity using Adodc. ... .

Once data is shown on the form,then set the datagrid property for adding ,deleting and updating the records..

Add search capability to the datagrid..

Chủ Đề