Unicode Controls & Classes for VB6 - Version 4

ctlUniGrid Control

Advanced Unicode grid
Check common properties here

Enums
Name Description
eUniGrid_ColumnAlign Column alignment constants
eUniGrid_ColumnType Column type constants
Events
Name Description
Click
DblClick
KeyDown
KeyPress
KeyUp
MouseDown MouseDown event
MouseMove MouseMove event
MouseUp MouseUp event
MouseWheel MouseWheel event
SelectionChange Occurs when a new row is selected
VScroll
HScroll
ColumnClick Raised when a column header is being clicked
OLEStartDrag
OLESetData
OLEGiveFeedback
OLEDragOver
OLEDragDrop
OLECompleteDrag
SortCompareRows Raised if you chose to sort a column using a custom event
OnOwnerDrawPicture Raised before measuring or drawing a cell, permits you to assign a picture to a cell on the fly
Properties
Name Type Description
AllowMultiLineText (Boolean) Permits you to use multiline text in grid cells
BackColor (OLE_COLOR) Gets or sets the Background color of the control
BorderColor (OLE_COLOR) Gets or sets the Border color
CellBackColor (Long) Gets or sets the background color of the passed cell
CellForeColor (Long) Gets or sets the text color for the passed cell
CellHeight (Long) Returns the height of the given cell
CellHorizBorder (Boolean) Gets or sets the ability to show the horizontal border of cells
CellsBorderColor (OLE_COLOR) Gets or sets the border color of cells
CellTag (Variant) Gets or sets the tag of the given cell
CellValue (Variant) Gets or sets the cell value of the given row/col
CellVerticalBorder (Boolean) Gets or sets the ability to show vertical border of cells
Col (Long) Gets or sets the current column
ColAlign (eUniGrid_ColumnAlign) Gets or sets the column data alignment (not for the header title)
ColAllowEmptyNumbers (Boolean) Gets or sets the ability to accept blank strings as value for numeric columns
ColHeaderAlign (eUniGrid_ColumnAlign) Gets or sets the column title alignment
ColKey (Variant) Returns the key of the given column
ColResizable (Boolean) Gets or sets the ability to resize a certain column with the mouse
ColRightToLeft (Boolean) Gets or sets the RTL support for the given column
ColSortable (Boolean) Gets or sets the ability to sort the given column (by mouse)
ColSortWithCustomEvent (Boolean) Gets or sets the ability to sort a certain column using a custom event
ColText (String) Gets or sets the title of a certain column
ColType (eUniGrid_ColumnType) Returns the column type
ColWidth (Long) Gets or sets the width of a certain column
CurrCellBackColor (Long) Gets or sets the background color of the given cell on the current row
CurrCellForeColor (Long) Gets or sets the text color for the given cell on the current row
CurrCellHeight (Long) Returns the height of the given cell on the current row
CurrCellTag (Variant) Gets or sets the tag for the given cell on the current row
CurrCellValue (Variant) Gets or sets the value of the cell in the given column on the current row
Enabled (Boolean) Enables or disables the control
FixedCols (Integer) Gets or sets the number of fixed columns, a fixed column never scrolls horizontally
Font (Font) Gets or sets the font used for text in the control, check the [ApplyFontChanges] for details
ForeColor (OLE_COLOR) Gets or sets the text color
FullRowSelect (Boolean) Returns/sets whether selecting a column highlights the entire row.
HeaderBackColor (OLE_COLOR) Gets or sets the background color of the header
HeaderForeColor (OLE_COLOR) Gets or sets the text color of the header area
HeaderStyle (eCtlButtonStyle) Gets or sets the style of the header
HideColumnHeaders (Boolean) Returns/sets whether or not the control's column headers are hidden
HScroll (Object) Returns a reference to the horizontal scrollbar (in case you want to customize it)
HScroll_Max (Long) Gets the maximum value of the horizontal scrollbar
HScroll_Value (Long) Gets or sets the value of the horizontal scrollbar
hWnd (Long) Returns the usercontrol window handle
MinRowHeight (Integer) Gets or sets the minimum row height
MouseIcon (Picture) Gets or sets the MouseIcon for the control
MousePointer (VBRUN.MousePointerConstants) Gets or sets the MousePointer for the control
MultiSelect (Boolean) Gets or sets the ability to select multiple rows
OLEDropMode (eCtlOLEDropMode) Gets or sets the OleDropMode for the control
OwnerDrawState (eOwnerDrawState) Gets the OwnerDraw status, by checking this flag you can load items (icons or images) only when needed
Row (Long) Gets or sets the current row
Rows (Long) Gets or sets the number of rows in the grid
RowSel (Boolean) Gets or sets the selection of a certain row
ScrollOnMouseWheel (Boolean) Gets or sets the ability to capture the mouse wheel and scroll the view
SelBackColor (OLE_COLOR) Gets or sets the background color of the list item selector
SelectItemOnRightClick (Boolean) Permits the selection of items also when pressing the right mouse button (like the standard control)
SelectorStyle (eCtlButtonStyle) Gets or sets the style of the row selector
SelForeColor (OLE_COLOR) Gets or sets the foreground color of the list item selector
ShowFocus (Boolean) If True, draws the focus rectangle when the control gains the keyboard focus
StandardScrollBars (Boolean) Returns/sets whether or not the control uses standard or styled scrollbars
Striped (Boolean) If True, uses a different background color for even and odd rows
Tip (String) Gets or sets the Unicode Tooltip for the control
VScroll (Object) Returns a reference to the vertical scrollbar (in case you want to customize it)
VScroll_Max (Long) Gets the maximum value of the vertical scrollbar
VScroll_Value (Long) Gets or sets the value of the vertical scrollbar
Methods
Name Type Description
AddColumn Adds a column to the list, at least one column must be added before using the list
AddRow Adds a new row to the grid
ApplyFontChanges When setting a new font on the control you need to call this function in order to refresh the interface
BeginUpdate Permits you to start a long-time update on the control (for example by adding 1000 elements) without sending out many and many events. So it is faster!
Use un conjunction with [EndUpdate]
Clear Clears the list and optionally the header
ColExists (Boolean) Checks if a certain column exists
Cols (Integer) Returns the number of columns in the grid
CountSelected (Long) Returns the number of selected items when using MultiSelection
EndUpdate Terminates a [BeginUpdate] reactivating the control after a long-time update
FocusSelectedRow Focuses the selected row by scrolling if necessary
FormatNumber (String) Format a number using a specified format
GetCellAbsRect Returns the coordinates of the given cell
GetCellPicture Gets picture information for the given cell
GetCellRect Returns the coordinates of the given cell
GetCellRectByCoords Finds the cell on the given coordinates and returns the cell rectangle
GetColByAbsX (Long) Returns the column number relative to a certain X coordinate (the X coordinate with the HScroll_Value)
GetColByX (Long) Returns the column number relative to a certain X coordinate (the X coordinate without the HScroll_Value as obtained by the MouseMove, MouseDown and MouseUp events)
GetColX (Long) Returns the absolute X coordinate relative to a certain column number (the X coordinate + the HScroll_Value)
GetCurrCellPicture Gets picture information for the cell in the given column on the current row
GetRowByAbsY (Long) Returns the row number relative to the given Y coordinate (the Y coordinate with the VScroll_Value)
GetRowByY (Long) Returns the row number relative to the given Y coordinate (the Y coordinate without the VScroll_Value as obtained by the MouseMove, MouseDown and MouseUp events)
GetRowY (Long) Returns the absolute Y coordinate of a certain row (the Y coordinate + the VScroll_Value).
GetVisibleRows (Integer) Returns the number of visible rows in the viewport
IsHeaderCoord (Boolean) Returns True if the given y coordinate is used for displaying the header
IsRowCompletelyVisible (Boolean) Checks if the given row is completely visible
NoUpdate Terminates a [BeginUpdate] reactivating the control after a long-time update
Doesn't refresh the control view
OLEDrag Starts an OLEDrag operation
Refresh Redraws the control
RemoveColumn Removes a certain column
RemoveRow Removes the given row
SelectAll Selects all items
SelectRange Selects a range of items
SetCellPicture Sets the picture for the given cell
SetColFormat Sets the formatting options when displaying a Numeric column in the grid
SetCurrCellPicture Sets the picture for the cell in the given column on the current row
SortByColum Sorts the grid on a certain column
ViewPortHeight (Long) The Viewport height
ViewPortWidth (Long) The Viewport width
Remarks
How to use this control:
First of all you need to add columns to the list using the [AddColumn] method; you can specify keys for columns.
Then you can add rows using the [AddRow] method (use also the [BeginUpdate], [EndUpdate] methods)



Option Explicit

Private Sub pvLoadRows()
Dim sEl As String
Dim i As Integer

Dim oWrap As New HexUniControls.clsCommonWrapper

Dim sChin As String
Dim sJap As String
Dim sArab As String

sChin = oWrap.HextoStr("0XqYsRYuxO9HalY39PKHVVAG4AaQBjAG8AZABlAA==4F")
sJap = oWrap.HextoStr("0X7DDDMMQwkjB/Tyh1WTCLMFUAbgBpAGMAbwBkAGUAh2VXW5Iw9HalYw==17")
sArab = oWrap.HextoStr("0XRwYwBkcGIAAnBkQGRQZDBioGKAYpBiAAMwZIBkEGIABKBjMGRQYtBiAARAZDBiAAJwYzBioGLgYvBicGRQYgAEoGSAZGBkoGQwZIBi8GIABBBkoGIAAoBjEGJwZFBiwGQwY=1F")


With ctlUniGrid1
.BeginUpdate
.Clear

.AddColumn , , , "pic"
.AddColumn "First", , , , , , True
.AddColumn "Second", , , "sec", , [UniGrid Align Left], True
.AddColumn "Third", , , , , , True
.AddColumn "Forth - RTL", , , , , , True, , True
.AddColumn "Fifth", , , , , , True
.AddColumn "Boolean", , , "bool", , , True, , , [UniGrid Column Boolean]
.AddColumn "Numeric", , [UniGrid Align Right], "num", , , True, , , [UniGrid Column Numeric]

'Setup the formatting options for the numeric column
.SetColFormat "num", , , , 5, True, True, True

For i = 1 To 500

sEl = "" & vbTab & _
CInt(Rnd * 10) & sChin & vbTab & _
"&" & String(CInt(1 + Rnd * 10), "b") & vbTab & _
CInt(Rnd * 10) & sJap & vbTab & _
CInt(Rnd * 10) & sArab & vbTab & _
String(CInt(1 + Rnd * 30), "y")

.AddRow sEl

.CellValue(i, "bool") = IIf(i Mod 2 = 0, True, False)
.CellValue(i, "num") = Rnd * 5000

If i Mod 5 = 0 Then
.SetCellPicture i, "pic", MDIForm1.ctlImageBag1.GetPicture(eGlobalImgIndex.egii_x)
ElseIf i Mod 7 = 0 Then
.SetCellPicture i, "pic", MDIForm1.ctlImageBag1.GetPicture(eGlobalImgIndex.egii_help), , True
End If

Next


.CellBackColor(1, 2) = vbRed
.CellValue(1, "sec") = "changed using Key"

.Row = 5
.CurrCellValue("sec") = "ppp"

.EndUpdate
End With
End Sub

Private Sub ctlUniButtonImageXP2_Click()
ctlUniGrid1.FixedCols = 1
End Sub

Private Sub Form_Load()
pvLoadRows
End Sub