Option Explicit On 

Imports AxSftBoxLib45
Imports SftBoxLib45
Imports Softelvdm.OLEConvert

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private BoldFont As Font, ItalicFont As Font

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
Friend WithEvents picturePic As System.Windows.Forms.PictureBox
Friend WithEvents pictureSpecial As System.Windows.Forms.PictureBox
Friend WithEvents picturePin As System.Windows.Forms.PictureBox
Friend WithEvents SftBox1 As AxSftBoxLib45.AxSftBox
Friend WithEvents closeButton As System.Windows.Forms.Button
Friend WithEvents label1 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.picturePic = New System.Windows.Forms.PictureBox()
Me.pictureSpecial = New System.Windows.Forms.PictureBox()
Me.picturePin = New System.Windows.Forms.PictureBox()
Me.SftBox1 = New AxSftBoxLib45.AxSftBox()
Me.closeButton = New System.Windows.Forms.Button()
Me.label1 = New System.Windows.Forms.Label()
CType(Me.SftBox1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'picturePic
'
Me.picturePic.Image = CType(resources.GetObject("picturePic.Image"), System.Drawing.Bitmap)
Me.picturePic.Location = New System.Drawing.Point(299, 379)
Me.picturePic.Name = "picturePic"
Me.picturePic.Size = New System.Drawing.Size(22, 15)
Me.picturePic.TabIndex = 11
Me.picturePic.TabStop = False
Me.picturePic.Visible = False
'
'pictureSpecial
'
Me.pictureSpecial.Image = CType(resources.GetObject("pictureSpecial.Image"), System.Drawing.Bitmap)
Me.pictureSpecial.Location = New System.Drawing.Point(262, 379)
Me.pictureSpecial.Name = "pictureSpecial"
Me.pictureSpecial.Size = New System.Drawing.Size(22, 15)
Me.pictureSpecial.TabIndex = 10
Me.pictureSpecial.TabStop = False
Me.pictureSpecial.Visible = False
'
'picturePin
'
Me.picturePin.Image = CType(resources.GetObject("picturePin.Image"), System.Drawing.Bitmap)
Me.picturePin.Location = New System.Drawing.Point(226, 379)
Me.picturePin.Name = "picturePin"
Me.picturePin.Size = New System.Drawing.Size(22, 15)
Me.picturePin.TabIndex = 9
Me.picturePin.TabStop = False
Me.picturePin.Visible = False
'
'SftBox1
'
Me.SftBox1.Location = New System.Drawing.Point(6, 45)
Me.SftBox1.Name = "SftBox1"
Me.SftBox1.OcxState = CType(resources.GetObject("SftBox1.OcxState"), System.Windows.Forms.AxHost.State)
Me.SftBox1.Size = New System.Drawing.Size(388, 334)
Me.SftBox1.TabIndex = 8
'
'closeButton
'
Me.closeButton.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.closeButton.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.closeButton.Location = New System.Drawing.Point(321, 8)
Me.closeButton.Name = "closeButton"
Me.closeButton.Size = New System.Drawing.Size(73, 30)
Me.closeButton.TabIndex = 7
Me.closeButton.Text = "Close"
'
'label1
'
Me.label1.Location = New System.Drawing.Point(6, 8)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(307, 37)
Me.label1.TabIndex = 6
Me.label1.Text = "This sample shows how bitmaps, colors, fonts and multiple text lines can be used." & _
""
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.CancelButton = Me.closeButton
Me.ClientSize = New System.Drawing.Size(400, 386)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.picturePic, Me.pictureSpecial, Me.picturePin, Me.SftBox1, Me.closeButton, Me.label1})
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "Form1"
Me.Text = "Softel vdm, Inc. - Features Sample"
CType(Me.SftBox1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)

    End Sub

#End Region

'--locate-marker--

Private Sub closeButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles closeButton.Click
    Application.Exit()
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    BoldFont = New Font(SftBox1.Font, FontStyle.Bold)
    ItalicFont = New Font("Arial", 8, FontStyle.Italic)

    Dim index As Integer
    SftBox1.BulkUpdate = True
    For index = 0 To 29
        If index = 4 Then
            AddOneItem("Item " & index, "This cell text is very long", "Cell " & index & ",2")
        ElseIf index = 7 Then
            AddOneItem("Item " & index, "Cell " & index & ",1", "This cell text is also very long")
        Else
            AddOneItem("Item " & index, "Cell " & index & ",1", "Cell " & index & ",2")
        End If
    Next
    SftBox1.BulkUpdate = False

    SftBox1.get_Column(0).Width = SftBox1.Width / 4
    SftBox1.get_Column(1).Width = SftBox1.Width / 4
    SftBox1.RowHeaders.MakeOptimal(0)
    SftBox1.get_Column(2).MakeOptimal(0)
    SftBox1.Items.RecalcHorizontalExtent(0)
End Sub

Private Function AddOneItem(ByVal Cell0 As String, ByVal Cell1 As String, ByVal Cell2 As String) As Integer
    Dim index As Integer
    index = SftBox1.Items.Add(Cell0)
    SftBox1.get_Cell(index, 1).Text = Cell1
    If index Mod 4 = 0 Then
        SftBox1.get_Cell(index, 1).Image.NETImageObject = pictureSpecial.Image
        If index Mod 8 = 0 Then SftBox1.get_Cell(index, 1).ImageHAlign = SftBoxHAlignConstants.halignSftBoxRight
    End If
    SftBox1.get_Cell(index, 2).Text = Cell2
    If index Mod 5 = 0 Then
        SftBox1.get_Cell(index, 2).Image.NETImageObject = picturePin.Image
        If index Mod 10 = 0 Then SftBox1.get_Cell(index, 2).ImageHAlign = SftBoxHAlignConstants.halignSftBoxRight
    End If
    If index Mod 3 = 0 Then
        SftBox1.get_Item(index).RowHeader.Image.NETImageObject = picturePic.Image
        If index Mod 6 = 0 Then SftBox1.get_Item(index).RowHeader.ImageHAlign = SftBoxHAlignConstants.halignSftBoxRight
    End If
    If index Mod 6 = 0 Then SftBox1.get_Cell(index, 0).Font = OLECvt.ToIFontDisp(BoldFont)
    If index Mod 7 = 0 Then SftBox1.get_Cell(index, 1).Font = OLECvt.ToIFontDisp(ItalicFont)
    AddOneItem = index
End Function

End Class