using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Softelvdm.SftTabsNET; using Softelvdm.Controls; namespace PartsSample1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { // This sample demonstrates how the various parts of a tab control are used in tabs. // To prepare for this sample, create a new project with a blank form and add // a SftTabs/NET control named sftTabs1. // In addition, adjust the following FromFile method to use a (small) bitmap // that is located on your system. Image img1 = Bitmap.FromFile("..\\..\\test1.png"); Image img2 = Bitmap.FromFile("..\\..\\test2.png"); sftTabs1.Initializing = true; // First Tab TabClass tab = sftTabs1.TabCollection.Add(); tab.Orientation = OrientationOptionalEnum.Vertical; TextPartClass textPart = new TextPartClass("&First Tab"); textPart.PartAlignment = PartAlignmentEnum.Center; textPart.HAlign = HAlignmentOptionalEnum.Center; tab.Parts.Add(textPart); ImagePartClass imagePart= new ImagePartClass(img1); imagePart.PartAlignment = PartAlignmentEnum.Center; imagePart.HAlign = HAlignmentOptionalEnum.Center; tab.Parts.Add(imagePart); // Second Tab tab = sftTabs1.TabCollection.Add(); ButtonPartClass buttonPart = new ButtonPartClass(); buttonPart.Text = ">"; buttonPart.Action += new GenericPartClass.ActionEventHandler(buttonPart_Action); buttonPart.PartAlignment = PartAlignmentEnum.Center; tab.Parts.Add(buttonPart); CheckBoxPartClass checkboxPart = new CheckBoxPartClass(CheckBoxStateEnum.Checked); checkboxPart.PartAlignment = PartAlignmentEnum.Center; checkboxPart.Action += new GenericPartClass.ActionEventHandler(checkboxPart_Action); tab.Parts.Add(checkboxPart); textPart = new TextPartClass("Tab &Two"); textPart.PartAlignment = PartAlignmentEnum.Center; textPart.BackColorSelected = Color.Green; textPart.Angle = 315; tab.Parts.Add(textPart); // Third Tab tab = sftTabs1.TabCollection.Add(); textPart = new TextPartClass("Third Tab (&3)"); textPart.PartAlignment = PartAlignmentEnum.Center; tab.Parts.Add(textPart); imagePart = new ImagePartClass(); imagePart.Image = img2; imagePart.VisibleAppearance = VisibleAppearanceEnum.OwnerSelected; imagePart.PartAlignment = PartAlignmentEnum.Center; tab.Parts.Add(imagePart); // Make the first tab active sftTabs1.Current = 0; sftTabs1.Initializing = false; } void checkboxPart_Action(object sender, ActionEventArgs e) { // A checkbox part automatically checks/unchecks the checkbox, and // it automatically makes the containing tab the selected tab. // To prevent the tab from being selected, use the CancelMode method: sftTabs1.CancelMode(); } void buttonPart_Action(object sender, ActionEventArgs e) { TabClass tab = (TabClass) e.Part.PartOwner; MessageBox.Show("The button was clicked"); // A button part automatically makes the containing tab the selected tab. // But, because we changed the input focus using the message box above, // tab switching was cancelled. So, we can explicitly make the tab // the selected tab, if desired: sftTabs1.Current = tab.Index; } } }