|AbsGrid is an OCX for VB6 projects that display a very flexible grid control.
It's based upon the famous vbaccelerator sgrid 2 control
want to learn how to install and quickly use it ? click here.
And of course, it's free.
FeaturesI have enhanced sgrid2 by adding the following :
|added a new event : CellClick||
note that CellClick event is raised after the MouveDown event, and before eventually RequestEdit one.
This event is fired only for colomns that allow it (see ColumnFireClickEvent)
|new property : ColumnFireClickEvent||
allow to raise even CellClick on a column (default is false)
|new property : ColumnNoEdit||
disable editing for a column (default is false)
note also that you can use a new optional parameter of AddColumn to define noEdit
|new property : noHighLightColor||
disable drawing of Highlight selector (default is false)
|new sub TakeObjForEditing||
|new property GroupRowColorMode||
values are :
|new property : GroupExpandMode||This property setup how groups are expanded.
|new property : InlineGrp||
value are true or false.
|new property : InlineGrpFont||you can define a specific font for grouped column,
|new property : InlineGrpDisp||define how inlined group are displayed,
|new function : InlineGrpActive||
|new function : ExpandAllGroups||
|new function : Search||
it return an array of found value (row number)
This function supersed orginial search system that is not so flexible.
|added a 3rd parameter to AutoHeightRow||now support a 3rd parameter (optional, default is false) :
now return the value (it's now function instead of sub) it now return computed height for the requested row.
Check this page for more informations about the new behavior.
|fixed a bug at EndEdit function|
|optimisations||performed a little bit of optimisation (and cleaning dead code) on UserControl_DblClick(), prop get Font()|
|added gradiant||you can control the gradian mode with
note that MsImg32.dll is not present on every system.
See this page to see information about gradiants
|new property : InlineGrpTxtOffset||
|I created a method to make life easier about editing cell content.
First place your grid (
You can change textbox settings (appearance : flat...) and don't forget to change
Private Sub Grid1_RequestEdit(ByVal lRow As Long, ByVal lCol As Long, ByVal iKeyAscii As Integer, bCancel As Boolean) Grid1.TakeObjForEditing(Text1, lRow, lCol, Grid1.Left, Grid1.Top) End SubThis method will automatically move the Text1 control to the right place, place cell content into it, make it visible, and set focus on it to allow user starting editing. for nice stuff, create these two subs :
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer) Select Case KeyCode Case 9, 13, 27 ' tab, return, escape Grid1.EndEdit KeyCode = 0 End Select End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) Select Case KeyAscii ' Stop annoying beeps... Case 9, 13, 27 KeyAscii = 0 End Select End Suband just don't forget to clean with :
Private Sub Grid_CancelEdit() Text1.Visible = False End SubNote this is also working for Combo or ListBox control.
result = AGrid1.Search(method, colkey, value, nb)
Perform a multi-purpose search on a column (defined with colkey)
list of accepted methods :
col_FullTextMatch: exactly match cell
col_InStrTextMatch: match if value is found inside cell content
col_TextStart: match if cell text start with value
col_NumericEq: match if it's numeric and if equal to cell content
col_NumericGt: match if it's numeric and if greater than cell content
col_NumericLt: match if it's numeric and if lower than cell content
col_HasIcon: match if cell has icon
col_IconId: match for cell that have this icon id
col_CellItemData: match for CellItemData
col_Selected: match if the cell is selected
row_NotVisibleRow: match if the row is not visible
row_ItemData: match for row ItemData
row_IsGrouped: match if the row is grouped
row_IsNotGrouped: match if the row is not grouped
row_CollapsedGroup: match if the row is collapsed
row_GroupLevel: match for row that match the requested grouplevel
the array of long contain row id.
Dim result() As Long, n as long result = Grid.Search(col_InStrTextMatch,"colkey","patern",n) for i=0 to n 'do something about result(i).... next
As usual grouping system is buggy on SGrid2 (try to group cols with icon in header for example) and as it's not easy or possible to create group in the code itself, I decided to create function that help to make such group in code.
You don't have anymore to use
Now, you will use
See here how to create 2 cascaded group for column "c1" and "c4" :
Grid.inlineGrp=true Grig.InlineGrpActive("c1","c4")That's all ! how could be it more simplier ?
also you can define specific font for grouping :
and you can choose displayed gadget of group header... (a gradiant, a box...)
example of gadgets :
|classic underlined gradiant (3)
||classic [+]/[-] boxes (10)
|double vertical gradiant (8)
||vertical gradiant with triangles (80)
set f as new Stdfont f.Name="Verdana" f.italic=true set Grid.InlineGrpFont=f Grid.InlineGrpDisp=3 '3=gradiantThis example cover inlineGroup feature : download project source
|sample project||feature covered|
|prj1 (8kb)||cell font and color, inline-grouping|
|prj2 (13kb)||cell text property, rowheight, font|
|prj3 (52kb)||cell font and color, cell icons and header icon, cell click event, grid selection property|
to be continued...
downloadbinary file (absgrid.ocx) (472 kb)
complete absGrid source (104 kb)
note that sources file need to be cleaned up a little bit.
LinkAbsGrid is created upon vbaccelerator SGid2 source.
But vbAccelerator does not provide any support about AbsGrid.
Direct link to SGrid2 page from vbaccelerator.
SGrid2 Licence is "FREE SOURCE CODE - ENJOY!".
known issueI found a bug that AllowGrouping with icon in the header may cause the application to crash. (to be check if this bug exist in sgrid2)
to be continued...