With 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.
- More properties and methods.
How it works
When using my ActiceX Control (MKGrid) the grid begins with one row as Data grid control then increase rows one by one after edit current row.
When you bind the grid with database file, my ActiveX will look for the Date field, if any then put Date picker at the Date column, also my ActiveX will look for the Boolean field (Yes, No), if any then put Check box at the Boolean column without user intervention, this means that the user does not need to specify the type field in this case.
In the following table you can read about some Methods and some properties as examples:
| Method/Property | Explanation | Example |
| ComboItemsList | Set the List of items [ComboList] to the Combo box at the Column #ComboCol. | int c = 4; |
| DeleteRecord | Deletes the current Record from database file. | MKGrid1.DeleteRecord; |
| InsertRow | Insert new Row to unbound Grid. | MKGrid1.InsertRow; |
| set_ColumnHidden | Returns or sets a value indicating whether a specified column is hide. | MKGrid1.set_ColumnHidden(4, false); |
| set_ColumnType | Returns or sets the type of control to show in a column. | MKGrid1.set_ColumnType (4, KGrid.grdColumnType.colCheckBox) |
| LoadGridByQuery | Populate the grid with query [GridSQL] from the file [MyDataFile]. | string MyDataFile = Application.StartupPath + @"\DataFiles\" + "test.mdb"; |
| LoadGridFromTable | Bind the Grid to the Table [mdbTable] from the database file [mdbDataFile]. | string MyDataFile = Application.StartupPath + @"\DataFiles\" + "test.mdb"; |
You can read about more Methods and Properties in my test project.
Examples
About columns:
MKGrid1.Rows = 2; // number of rows
MKGrid1.Cols = 6; // number of columns
// Set Header of column:
MKGrid1.set_ColHeaderText(1, "Emp ID");
MKGrid1.set_ColHeaderText(2, "Emp Name");
MKGrid1.set_ColHeaderText(3, "B_Date");
MKGrid1.set_ColHeaderText(4, "Salary");
MKGrid1.set_ColHeaderText(5, "Married");
MKGrid1.set_ColHeaderText(6, "City");
About combo box:
// items list for Combo box.
// we are using the slash "/" as delimiter between items.
int c = 6;
string strList = "Ankara/Berlin/Cairo/London/Los Angeles/Madrid/Marseille/";
// fill CombBox at column #6 with previous list:
MKGrid1.ComboItemsList(ref c, ref strList);
About Date Picker and Check box:
// Set Date Picker and Check box:
MKGrid1.set_ColumnType(3, KGrid.grdColumnType.colDateControl); // Date control at column #3
MKGrid1.set_ColumnType(5, KGrid.grdColumnType.colCheckBox); // CheckBox at column #5
No comments:
Post a Comment