# Function Reference

# _GUICtrlHeader_AddItem

Adds a new header item

#include <GuiHeader.au3>
_GUICtrlHeader_AddItem ( $hWnd, $sText [, $iWidth = 50 [, $iAlign = 0 [, $iImage = -1 [, $bOnRight = False]]]] )

## Parameters

$hWnd | Handle to the control
$sText | Item text
$iWidth | [optional] Item width
$iAlign | [optional] Text alignment: 0 - Text is left-aligned 1 - Text is right-aligned 2 - Text is centered
$iImage | [optional] 0-based index of an image within the image list
$bOnRight | [optional] If True, the column image appears to the right of text

## Return Value

Success: | the index of the new item.
Failure: | -1.

## Related

_GUICtrlHeader_DeleteItem, _GUICtrlHeader_InsertItem

## Example

### Example 1

    #include "Extras\HelpFileInternals.au3"

    #include <GUIConstantsEx.au3>
    #include <GuiHeader.au3>

    Example()

    Func Example()
        ; Create GUI
        Local $hGUI = GUICreate("Header AddItem (v" & @AutoItVersion & ")", 450, 300, 100, 100)

        Local $hHeader = _GUICtrlHeader_Create($hGUI)
        _MemoCreate(2, 52, 444, 220)

    ;~  _GUICtrlHeader_SetUnicodeFormat($hHeader, True)

        GUISetState(@SW_SHOW)

        ; Add columns
        _GUICtrlHeader_AddItem($hHeader, "Column 1", 75)
        _GUICtrlHeader_AddItem($hHeader, "Column 2", 75)
        _GUICtrlHeader_AddItem($hHeader, "Column 3", 75)
        _GUICtrlHeader_AddItem($hHeader, "Column 4", 75)

        _MemoWrite("Column count: " & _GUICtrlHeader_GetItemCount($hHeader))

        _MemoMsgBoxStatus("", -1, $hGUI) ; no more action, wait GUI for closing

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
    EndFunc   ;==>Example

### Example 2 : Header Add Item to an External process

    #include "Extras\HelpFileInternals.au3"

    #include <GuiHeader.au3>

    Example()

    Func Example()
        Local $sFromTo
        Local $hWin = _MemoRunAU3OutProcess($sFromTo, True)

        Local $hHeader = _MemoCreateOutProcess($hWin, "SysHeader32", 3, $sFromTo)

        _GUICtrlHeader_AddItem($hHeader, "<<<Column 5", 75)

        ; Show column count
        _MemoWrite("Column count: " & _GUICtrlHeader_GetItemCount($hHeader))

        _MemoMsgBoxStatus("", Default, $hWin) ; no more action, wait GUI for closing, close also OutProcess GUI

    EndFunc   ;==>Example