HeaderPane
Main
Hide
Share Link
Print

Features Sample (C#)

This sample illustrates a simple combo box with fonts, bitmaps.

The source code is located at C:\Program Files (x86)\Softelvdm\SftBox OCX 6.0\Samples\Visual Studio - CSharp\Features\Form1.cs.


        private void closeButton_Click(object sender, System.EventArgs e)
        {
            Application.Exit();
        }

        private void Form1_Load(object sender, System.EventArgs e)
        {
            foreach (Control c in Controls) {
                AxSftBoxLib60.AxSftBox box = c as AxSftBoxLib60.AxSftBox;
                if (box != null) {
                    box.DarkMode = SftBoxLib60.SftBoxDarkModeConstants.darkSftBoxAuto; // follow the Windows dark mode setting
                    box.HighContrastMode = SftBoxLib60.SftBoxHighContrastConstants.highContrastSftBoxAuto; // follow the Windows High Contrast setting
                }
            }

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

            int index;
            SftBox1.BulkUpdate = true;
            for (index = 0 ; index < 30 ; ++index) {
                if (index == 4)
                    AddOneItem("Item " + index, "This cell text is very long", "Cell " + index + ",2");
                else if (index == 7)
                    AddOneItem("Item " + index, "Cell " + index + ",1", "This cell text is also very long");
                else
                    AddOneItem("Item " + index, "Cell " + index + ",1", "Cell " + index + ",2");
            }
            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);
        }

        int AddOneItem(string Cell0, string Cell1, string Cell2)
        {
            int index = SftBox1.Items.Add(Cell0);
            SftBox1.get_Cell(index, 1).Text = Cell1;
            if (index % 4 == 0) {
                SftBox1.get_Cell(index, 1).Image.NETImageObject = pictureSpecial.Image;
                if (index % 8 == 0)
                    SftBox1.get_Cell(index, 1).ImageHAlign = SftBoxHAlignConstants.halignSftBoxRight;
            }
            SftBox1.get_Cell(index, 2).Text = Cell2;
            if (index % 5 == 0) {
                SftBox1.get_Cell(index, 2).Image.NETImageObject = picturePin.Image;
                if (index % 10 == 0)
                    SftBox1.get_Cell(index, 2).ImageHAlign = SftBoxHAlignConstants.halignSftBoxRight;
            }
            if (index % 3 == 0) {
                SftBox1.get_Item(index).RowHeader.Image.NETImageObject = picturePic.Image;
              if (index % 6 == 0)
                  SftBox1.get_Item(index).RowHeader.ImageHAlign = SftBoxHAlignConstants.halignSftBoxRight;
            }
            if (index % 6 == 0) {
                SftBox1.get_Cell(index, 0).Font = OLECvt.ToIFontDisp(BoldFont);
            }
            if (index % 7 == 0) {
                SftBox1.get_Cell(index, 1).Font = OLECvt.ToIFontDisp(ItalicFont);
            }
            return index;
        }
	}

}

Last Updated 11/22/2026 - (email)
© 2026 Softel vdm, Inc.