Using Grid ActiveX Control With VB.NET
Using the new ActiveX control (MKGrid) with VB.Net, you can read my article about using MKGrid control with C#.
Using the new ActiveX control (MKGrid) with VB.Net, you can read my article
about using MKGrid
control with C#,
With my ActiveX control you can:
- Bind to database file.
- Add, Edit and delete records.
- Use Combo box, Date picker and Check box at any column.
- Add row, delete row, insert row to unbound grid.
- Hide column, lock column, resize column and sort column.
- Save unbound grid after edit it as *.mdb file or *.htm file.
- After edit cell and leave it the cell will be saved.
- More properties and methods.
- Using my AcriveX MKGrid in C# and VB.NET With differences in the names of some properties and its parameters.
When using my
ActiveX control (MKGrid) the grid begins with one row as a Data grid control
then increases rows one by one after editing the current row.
When you bind the grid with a database file, my ActiveX will look for the Date
field; if there are any then put Date picker at the Date column.
Also my ActiveX will look for the Boolean field (Yes, No); if there are any then
put Check box at the Boolean column without user intervenes,
this means that the user does not need to specify the type field in this case.
In the following tables you can read about some Methods and some properties as
ComboItemsList (ComboCol, ComboList)
Set the List of items [ComboList] to the Combo box at the Column #ComboCol.
MKGrid.ComboItemsList (4, "Apple/Banana/Orange/Melon/Peach/Strawberry")
Deletes the current Record from database file.
Insert new Row to unbound Grid.
Returns or sets a value indicating whether a specified column is hide.
set_ColumnType (number, ColType)
Returns or sets the type of control to show in a column.
MKGrid.set_ColumnType (4, KGrid.grdColumnType.colCheckBox)
LoadGridByQuery( MyDataFile, GridSQL)
Populate the grid with query [GridSQL] from the file [MyDataFile].
Dim MyDataFile As String = Application.StartupPath & "\" & "Test.mdb"
Dim MySql As String = "SELECT * FROM Customers"
MKGrid.LoadGridByQuery (MyDataFile, MySql)
LoadGridFromTable( mdbDataFile, mdbTable)
Bind the Grid to the Table [mdbTable] from the database file [mdbDataFile].
Dim MyDataFile As String = StartupPath & "\" & "Test.mdb"
Dim MyTable As String = "Customers"
MKGrid.LoadGridFromTable (MyDataFile, MyTable)
Examples from the Code
About combo box:
About Date Picker and Check box:
>> When extract the files *.zip You can find:
The ActiveX control KGrid.ocx
VB.NET Project to test ActiveX.
Test_EN.mdb, Test_Ar.mdb and MyMarket.mdb.
MKGrid help file.
>> Set my ActiveX "KGrid.ocx"
in your program directory, but it is better if you set it in the directory:
"c:\windows\system32\" then register the ActiveX control by run the following
>> To add my ActiveX "MKGrid" control to your form:
- open Components dialog then click Browse
- from its directory or c:\windows\system32\ you can add the ActiveX.
>> You can refer to the help file for all methods and properties. If there are
any problems please let me know.
>> I create a project to test my control; I write its code under VisualBasic.Net
>> If you use VS2008 or VS2010 you can copy the code from the VS2003 project,
then paste into your project.
I hope this article is useful and helps you to create your applications. If you
have any idea, please tell me.