// Create the Calculator Control.
this.currencyTextBox1 = new CurrencyTextBox();
// Set the initial value.
this.currencyTextBox1.Text = "$1.00";
// Set the clipmode.
this.currencyTextBox1.ClipMode = CurrencyClipModes.IncludeFormatting;
// Set formatting properties.
this.currencyTextBox1.CurrencyDecimalDigits = 2;
this.currencyTextBox1.CurrencyDecimalSeparator = ".";
this.currencyTextBox1.CurrencyGroupSeparator = ",";
this.currencyTextBox1.CurrencyGroupSizes = new int[] {3};
this.currencyTextBox1.CurrencyNegativePattern = 1;
this.currencyTextBox1.CurrencyNumberDigits = 27;
this.currencyTextBox1.CurrencyPositivePattern = 0;
this.currencyTextBox1.CurrencySymbol = "$";
this.currencyTextBox1.ForeColor = System.Drawing.Color.Black;
this.currencyTextBox1.NegativeColor = System.Drawing.Color.Red;
this.currencyTextBox1.NegativeSign = "-";
this.currencyTextBox1.PositiveColor = System.Drawing.Color.Black;
this.currencyTextBox1.Size = new System.Drawing.Size(256, 20);
this.currencyTextBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
// Add the CurrencyTextBox control to the form.
this.Controls.Add(this.currencyTextBox1);
this.progressBarEx1 = new ProgressBarAdv();
this.progressBarEx1.BackGradientEndColor = System.Drawing.SystemColors.ControlLightLight;
this.progressBarEx1.BackGradientStartColor = System.Drawing.SystemColors.ControlDark;
this.progressBarEx1.BackgroundStyle = ProgressBarBackgroundStyles.VerticalGradient;
this.progressBarEx1.BackSegments = false;
this.progressBarEx1.Border3DStyle = System.Windows.Forms.Border3DStyle.RaisedOuter;
this.progressBarEx1.FontColor = System.Drawing.SystemColors.HighlightText;
this.progressBarEx1.Location = new System.Drawing.Point(240, 8);
this.progressBarEx1.ProgressStyle = ProgressBarStyles.Tube;
this.progressBarEx1.SegmentWidth = 20;
this.progressBarEx1.Size = new System.Drawing.Size(400, 23);
this.progressBarEx1.TextShadow = false;
this.progressBarEx1.ThemesEnabled = false;
this.progressBarEx1.TubeEndColor = System.Drawing.SystemColors.Control;
this.progressBarEx1.TubeStartColor = System.Drawing.SystemColors.ControlDark;
this.progressBarEx1.Value = 79;
this.progressBarEx1 = new ProgressBarAdv();
this.progressBarEx1.BackGradientEndColor = System.Drawing.SystemColors.ControlLightLight;
this.progressBarEx1.BackGradientStartColor = System.Drawing.SystemColors.ControlDark;
this.progressBarEx1.BackgroundStyle = ProgressBarBackgroundStyles.VerticalGradient;
this.progressBarEx1.BackSegments = false;
this.progressBarEx1.Border3DStyle = System.Windows.Forms.Border3DStyle.RaisedOuter;
this.progressBarEx1.FontColor = System.Drawing.SystemColors.HighlightText;
this.progressBarEx1.Location = new System.Drawing.Point(240, 8);
this.progressBarEx1.ProgressStyle = ProgressBarStyles.Tube;
this.progressBarEx1.SegmentWidth = 20;
this.progressBarEx1.Size = new System.Drawing.Size(400, 23);
this.progressBarEx1.TextShadow = false;
this.progressBarEx1.ThemesEnabled = false;
this.progressBarEx1.TubeEndColor = System.Drawing.SystemColors.Control;
this.progressBarEx1.TubeStartColor = System.Drawing.SystemColors.ControlDark;
this.progressBarEx1.Value = 79;
The GroupBar class implements a container that can serve as a host for other controls.
The control is functionally similar to the Windows Forms
Each control in the GroupBar is associated with a
The GroupBar can be used in combination with the Syncfusion
When the
The GroupBar's automatic initialization should suffice for most applications and you should explicitly set this property only when you want to override the default menu provider assignment.
The GroupView control implements a list type control that can display a set of items where
each item is represented by an image and a descriptor. Items are implemented as
instances of the
The GroupView control is capable of displaying items with large or small icons in various combinable styles such as the default selectable style, button-type selection, full-item select and an icon-only flowview mode. All styles are available in the regular 3D or a FlatLook mode. The control also implements an IntegratedScrolling option that allows scrolling to be delegated to its parent container.
The GroupView control can be used in conjunction with the Essential Tools
using System.Windows.Forms;
namespace AutoLabel
{
public partial class Form1 : Form
{
private Syncfusion.Windows.Forms.Tools.AutoLabel autoLabel1;
public Form1()
{
InitializeComponent();
//Initialization
this.autoLabel1 = new Syncfusion.Windows.Forms.Tools.AutoLabel();
//Set the properties
this.autoLabel1.Text = "autoLabel1";
this.autoLabel1.BackColor = System.Drawing.Color.DarkGray;
this.autoLabel1.ForeColor = System.Drawing.Color.DarkBlue;
this.autoLabel1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.autoLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
// Add the AutoLabel control to the form.
this.Controls.Add(this.autoLabel1);
}
}
}
// Binding a control to the manager programmatically.
this.borderLayout1 = new BorderLayout();
this.borderLayout1.ContainerControl = this;
// Set the border-position of the button.
this.borderLayout1.SetPosition(this.btnNorth, BorderPosition.North);
this.borderLayout1.SetPosition(this.btnSouth, BorderPosition.South);
this.borderLayout1.SetPosition(this.btnCenter, BorderPosition.Center);
this.borderLayout1.SetPosition(this.btnEast, BorderPosition.East);
this.borderLayout1.SetPosition(this.btnWest, BorderPosition.West);
// Binding a Control to the manager programmatically.
this.cardLayout1 = new CardLayout();
// Set the container control; all the child controls of this container control are
// automatically registered as children with the manager and get default card names.
this.cardLayout1.ContainerControl = this.panel1;
// Set custom card names to replace default card names.
this.cardLayout1.SetCardName(this.label1, "MyCard1");
// To select a card manually, use the SelectedCard property.
this.cardLayout1.SelectedCard = "MyCard1";
// Or move through the cards like this:
this.cardLayout1.Next();
this.cardLayout1.Previous();
// Binding a control to the manager programmatically:
this.flowLayout1 = new FlowLayout();
// Set the container control; all the child controls of this container control are
// automatically registered as children with the manager:
this.flowLayout1.ContainerControl = this.panel1;
// Set some properties on the manager:
this.flowLayout1.HGap = 20;
this.flowLayout1.Alignment = FlowAlignment.Near;
// You can prevent one or more child controls from being laid out, like this (the first argument for should be False).
// This will have the same effect as calling RemoveLayoutComponent:
this.flowLayout1.SetConstraints(this.label10, new FlowLayoutConstraints(false, HorzFlowAlign.Left, VertFlowAlign.Center, false, false, false));
// You can prevent automatic layout during the layout event.
// If you decide to do so, make sure to call flowLayout.LayoutContainer manually:
// this.flowLayout1.AutoLayout = false;
Also take a look at the project in Tools/Samples/Quick Start/
// Binding a control to the manager programmatically:
this.gridBagLayout1 = new GridBagLayout();
// Set the container control; all the child controls of this container control are
// automatically registered as children with the manager:
this.gridBagLayout1.ContainerControl = this.panel1;
this.gridBagLayout1.SetConstraints(
this.button1,
new GridBagConstraints(0, 0, 3, 1, 1, 0.2, AnchorTypes.Center, FillType.Both, new Insets(0, 0, 0, 0), 0, 0, false)
);
this.gridBagLayout1.SetConstraints(
this.button2,
new GridBagConstraints(0, 1, 1, 3, 0.2, 0.6, AnchorTypes.Center, FillType.Both, new Insets(0, 0, 0, 0), 0, 0, false)
);
// Exclude button3 from layout:
this.gridBagLayout1.SetConstraints(this.button3, GridBagConstraints.Empty);
// Modify an exisiting constraint:
GridBagConstraints constraints1 = this.gridBagLayout1.GetConstraintsRef(this.button1);
constraints1.Fill = FillType.Horizontal;
// You can prevent automatic layout during the layout event.
// If you decide to do so, make sure to call gridBagLayout1.LayoutContainer manually:
// this.gridBagLayout1.AutoLayout = false;
// Binding a Control to the manager programmatically:
this.gridLayout1 = new Syncfusion.Windows.Forms.Tools.GridLayout();
// Set the container control; all the child controls of this container control are
// automatically registered as children with the manager:
this.gridLayout1.ContainerControl = this.innerPanel;
// Set some properties on the manager:
this.gridLayout1.Columns = 4;
this.gridLayout1.Rows = 5;
this.gridLayout1.HGap = 4;
this.gridLayout1.VGap = 4;
// You can ignore one or more child Control from being laid out, like this.
// This will have the same effect as calling RemoveLayoutComponent:
//this.gridLayout1.SetParticipateInLayout(this.button1, false);
// You can prevent automatic layout during the layout event:
// If you decide to do so, make sure to call gridLayout1.LayoutContainer manually:
// this.gridLayout1.AutoLayout = false;
Also take a look at the project in Tools/Samples/Quick Start/
public class MyRectangle : LayoutItemBase
{
public static Size PrefSize = new Size(0, 0);
protected Control parent;
protected Color color;
protected string text;
public MyRectangle(Control parent, Color color, string text)
{
this.parent = parent;
this.color = color;
this.text = text;
}
public void OnPaint( PaintEventArgs e)
{
e.Graphics.FillRectangle(new SolidBrush(color), this.Bounds);
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
RectangleF r = new RectangleF(Bounds.Left, Bounds.Top,
Bounds.Width, Bounds.Height);
e.Graphics.DrawString(text, Control.DefaultFont, SystemBrushes.ControlText, r, sf);
}
// This override is a good place to repaint.
// Or you can listen to BoundsChanged event in LayoutItemBase.
protected override void OnBoundsChanged()
{
parent.Invalidate(new Rectangle(0, 0, this.parent.Width, this.parent.Height));
}
public override System.Drawing.Size MinimumSize
{
get { return MyRectangle.PrefSize; }
}
public override System.Drawing.Size PreferredSize
{
get
{
return MyRectangle.PrefSize;
}
}
}
private void Form1_Load(object sender, System.EventArgs e)
{
this.SuspendLayout();
// Current layout manager (Update every time you change the manager)
// Layout Component 1:
this.myRect1 = new MyRectangle(this.gridBagLayout1.ContainerControl, Color.FromArgb(133, 191, 117), "Paint Area 1");
this.myRect1.Bounds = new Rectangle(10, 10, 80, 20);
this.myRect1.Visible = true;
// Layout Component 2:
this.myRect2 = new MyRectangle(this.gridBagLayout1.ContainerControl, Color.FromArgb(222, 100, 19), "Paint Area 2");
this.myRect2.Bounds = new Rectangle(10, 40, 80, 20);
this.myRect2.Visible = true;
// Layout Component 3:
this.myRect3 = new MyRectangle(this.gridBagLayout1.ContainerControl, Color.FromArgb(196, 214, 233), "Paint Area 3");
this.myRect3.Bounds = new Rectangle(10, 70, 80, 20);
this.myRect3.Visible = true;
// Sample GridBagConstraints:
GridBagConstraints gbc1 = new GridBagConstraints();
GridBagConstraints gbc2 = new GridBagConstraints();
GridBagConstraints gbc3 = new GridBagConstraints();
gbc1.Fill = FillType.Both;
gbc1.WeightX = 0.2;
gbc1.WeightY = 0.5;
gbc1.GridPosX = 0;
gbc1.GridPosY = 0;
gbc2.Fill = FillType.Both;
gbc2.WeightX = 0.2;
gbc2.WeightY = 0.5;
gbc2.GridPosX = 1;
gbc2.GridPosY = 0;
gbc3.Fill = FillType.Both;
gbc3.WeightX = 0.4;
gbc3.WeightY = 0.5;
gbc3.GridPosX = 0;
gbc3.GridPosY = 1;
gbc3.CellSpanX = 2;
// Add all the components that are to participate in Layout Management.
// For GridBagLayouts pass gbcs for GridBagLayouts:
this.gridBagLayout1.SetConstraints(this.myRect1.ToControl(), gbc1);
this.gridBagLayout1.SetConstraints(this.myRect2.ToControl(), gbc2);
this.gridBagLayout1.SetConstraints(this.myRect3.ToControl(), gbc3);
this.ResumeLayout(true);
}
// InitializeComponent
// Create the Masked edit box control:
this.maskedEditBox1 = new MaskedEditBox();
// Specifies if the prompt character can be entered:
this.maskedEditBox1.AllowPrompt = false;
// The mask string:
this.maskedEditBox1.Mask = ">?<????????????";
// The max length is set based on the mask:
this.maskedEditBox1.MaxLength = 13;
// The clip mode specifies if the literals are included:
this.maskedEditBox1.ClipMode = ClipModes.IncludeLiterals;
// The date time format:
this.maskedEditBox1.TimeSeparator = ':';
this.maskedEditBox1.DateSeparator = '-';
// The number format:
this.maskedEditBox1.DecimalSeparator = '.';
this.maskedEditBox1.ThousandSeparator = ',';
// Add the MaskedEditBox control to the form:
this.Controls.Add(this.maskedEditBox1);
Console.WriteLine("ValidationError in currencyTextBox1 InvalidText" + e.InvalidText);
Console.WriteLine("ValidationError in currencyTextBox1 StartPosition" + e.StartPosition );
Double doubleVal;
bool isNumber = Double.TryParse(currentTextValue, out doubleVal);
if (isNumber)
{
return CheckForMinMax(doubleVal.ToString(),true);
}
else
return true;
this.autoAppend = new AutoAppend();
this.autoAppend.SetAutoAppend(this.comboBox1, new AutoAppendInfo(true, "HttpAddress", this.comboBox1.Items, 30));
// To disassociate call this:
this.autoAppend.SetAutoAppend(this.comboBox1, new AutoAppendInfo(false, String.Empty, null, 30));
private void InitializeColorUIControl()
{
// Create the ColorUIControl.
Syncfusion.Windows.Forms.ColorUIControl clrUIControl = new Syncfusion.Windows.Forms.ColorUIControl();
// Set the ColorGroups to be displayed
clrUIControl.ColorGroups = ( Syncfusion.Windows.Forms.ColorUIGroups.CustomColors|
Syncfusion.Windows.Forms.ColorUIGroups.StandardColors|
Syncfusion.Windows.Forms.ColorUIGroups.SystemColors );
// Set the initially selected group and color.
clrUIControl.SelectedColorGroup = Syncfusion.Windows.Forms.ColorUISelectedGroup.SystemColors;
clrUIControl.SelectedColor = SystemColors.ControlDark;
// Provide a handler for the ColorUIControl.ColorSelected event.
clrUIControl.ColorSelected += new EventHandler(this.OnColorSelected);
}
// Handler for the ColorUIControl.ColorSelected event.
private void OnColorSelected(object sender, System.EventArgs e)
{
Color clrselected = (sender as ColorUIControl).SelectedColor;
}
Private Sub InitializeColorUIControl()
' Create an instance of the ColorUIControl.
Me.clrUIControl = New Syncfusion.Windows.Forms.ColorUIControl()
' Set the color groups to be shown.
Me.clrUIControl.ColorGroups = Syncfusion.Windows.Forms.ColorUIGroups.CustomColors Or Syncfusion.Windows.Forms.ColorUIGroups.StandardColors
' Set the initially selected group.
Me.clrUIControl.SelectedColorGroup = Syncfusion.Windows.Forms.ColorUISelectedGroup.CustomColors
' Subscribe to the ColorUIControl.ColorSelected event.
AddHandler Me.clrUIControl.ColorSelected, New System.EventHandler(AddressOf clrUIControl_ColorSelected)
End Sub
' Handler for the ColorUIControl.ColorSelected event.
Private Sub clrUIControl_ColorSelected(ByVal sender As Object, ByVal e As System.EventArgs)
Dim clrselected As Color = Me.clrUIControl.SelectedColor
End Sub 'clrUIControl_ColorSelected
This enumeration has a FlagsAttribute that allows a combination of its member values.
SfToolTip sfToolTip = new SfToolTip();
sfToolTip.SetToolTip(this.button1, "Sample Tooltip");
SfToolTip sfToolTip = new SfToolTip();
ToolTipInfo tooltipInfo1 = new ToolTipInfo();
ToolTipItem toolTipItem1 = new ToolTipItem();
toolTipItem1.Text = "Tooltip item 1 text";
ToolTipItem toolTipItem2 = new ToolTipItem();
toolTipItem2.Text = "Tooltip item 2 text";
toolTipInfo.Items.AddRange(new ToolTipItem[] { toolTipItem1, toolTipItem2});
sfToolTip.SetToolTipInfo( this.button2, toolTipInfo);
private void treeViewAdv1_MouseHover(object sender, System.EventArgs e)
{
TreeNodeAdv node=new TreeNodeAdv();
Point p=this.treeViewAdv1.PointToClient(Control.MousePosition);
node=this.treeViewAdv1.PointToNode(p);
Point mouseLoc=Control.MousePosition;
mouseLoc.Offset(10,10);
if(node==this.treeViewAdv1.Nodes[0])
{
this.toolTipAdv1.ShowPopup(mouseLoc);
}
if(node==this.treeViewAdv1.Nodes[1])
{
this.toolTipAdv2.ShowPopup(mouseLoc);
}
if(node==this.treeViewAdv1.Nodes[2])
{
this.toolTipAdv3.ShowPopup(mouseLoc);
}
if(node==this.treeViewAdv1.Nodes[3])
{
this.toolTipAdv4.ShowPopup(mouseLoc);
}
}
Private Sub treeViewAdv1_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs)
Dim node As TreeNodeAdv = New TreeNodeAdv()
Dim p As Point=Me.treeViewAdv1.PointToClient(Control.MousePosition)
node=Me.treeViewAdv1.PointToNode(p)
Dim mouseLoc As Point=Control.MousePosition
mouseLoc.Offset(10,10)
If node Is Me.treeViewAdv1.Nodes(0) Then
Me.toolTipAdv1.ShowPopup(mouseLoc)
End If
If node Is Me.treeViewAdv1.Nodes(1) Then
Me.toolTipAdv2.ShowPopup(mouseLoc)
End If
If node Is Me.treeViewAdv1.Nodes(2) Then
Me.toolTipAdv3.ShowPopup(mouseLoc)
End If
If node Is Me.treeViewAdv1.Nodes(3) Then
Me.toolTipAdv4.ShowPopup(mouseLoc)
End If
End Sub
private void ToolTipControl_BeforePopup(object sender, CancelEventArgs e)
{
Point pt=this.treeViewAdv1.PointToClient(new Point(MousePosition.X,MousePosition.Y));
TreeNodeAdv node=this.treeViewAdv1.GetNodeAtPoint(pt);
if(node!=null)
{
if(node.Text=="Node1" || node.Text=="Node3"||node.Text=="Node5"||node.Text=="Node7")
{
e.Cancel=true;
}
}
}
Private Sub ToolTipControl_BeforePopup(ByVal sender As Object, ByVal e As CancelEventArgs)
Dim pt As Point=Me.treeViewAdv1.PointToClient(New Point(MousePosition.X,MousePosition.Y))
Dim node As TreeNodeAdv=Me.treeViewAdv1.GetNodeAtPoint(pt)
If Not node Is Nothing Then
If node.Text="Node1" OrElse node.Text="Node3" OrElse node.Text="Node5" OrElse node.Text="Node7" Then
e.Cancel=True
End If
End If
End Sub
public override StyleInfoSubObjectIdentity CreateSubObjectIdentity(StyleInfoProperty sip)
{
return new ScrollerVisualStyleInfoSubObjectIdentity(this, sip);
}
public Form1()
{
InitializeComponent();
// It's recommended that you keep the PopupControlContainer unparented by
// any control on the form (which will be the default case as set up during design-time).
// Otherwise, the Form won't close sometimes after dropping down this popup!
this.popupControlContainer1.Parent.Controls.Remove(this.popupControlContainer1);
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.popupControlContainer1 = new Syncfusion.Windows.Forms.PopupControlContainer();
this.cancel = new System.Windows.Forms.Button();
this.OK = new System.Windows.Forms.Button();
this.popupTextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.sourceTextBox = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.dropDownBtn = new System.Windows.Forms.Button();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.popupControlContainer1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// popupControlContainer1
//
this.popupControlContainer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.popupControlContainer1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.cancel,
this.OK,
this.popupTextBox});
this.popupControlContainer1.Location = new System.Drawing.Point(80, 128);
this.popupControlContainer1.Name = "popupControlContainer1";
this.popupControlContainer1.Size = new System.Drawing.Size(120, 128);
this.popupControlContainer1.TabIndex = 0;
this.popupControlContainer1.Visible = false;
this.popupControlContainer1.Popup += new System.EventHandler(this.popupControlContainer1_Popup);
this.popupControlContainer1.CloseUp += new Syncfusion.Windows.Forms.PopupClosedEventHandler(this.popupControlContainer1_CloseUp);
this.popupControlContainer1.BeforePopup += new System.ComponentModel.CancelEventHandler(this.popupControlContainer1_BeforePopup);
//
// cancel
//
this.cancel.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.cancel.Location = new System.Drawing.Point(64, 96);
this.cancel.Name = "cancel";
this.cancel.Size = new System.Drawing.Size(48, 24);
this.cancel.TabIndex = 2;
this.cancel.Text = "Cancel";
this.cancel.Click += new System.EventHandler(this.cancelButton_Click);
//
// OK
//
this.OK.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.OK.Location = new System.Drawing.Point(8, 96);
this.OK.Name = "OK";
this.OK.Size = new System.Drawing.Size(48, 24);
this.OK.TabIndex = 1;
this.OK.Text = "OK";
this.OK.Click += new System.EventHandler(this.OK_Click);
//
// popupTextBox
//
this.popupTextBox.Multiline = true;
this.popupTextBox.Name = "popupTextBox";
this.popupTextBox.Size = new System.Drawing.Size(118, 90);
this.popupTextBox.TabIndex = 0;
this.popupTextBox.Text = "";
//
// label1
//
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label1.Location = new System.Drawing.Point(16, 56);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(256, 64);
this.label1.TabIndex = 1;
this.label1.Text = "Associate a PopupControlContainer with this TextBox. And also transfer data back " +
"and forth between the popup and the TextBox.";
//
// sourceTextBox
//
this.sourceTextBox.Location = new System.Drawing.Point(40, 128);
this.sourceTextBox.Name = "sourceTextBox";
this.sourceTextBox.Size = new System.Drawing.Size(200, 20);
this.sourceTextBox.TabIndex = 2;
this.sourceTextBox.Text = "Alt+DownArrow for popup";
this.sourceTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBoxPopupParent_KeyDown);
//
// groupBox1
//
this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.dropDownBtn});
this.groupBox1.Location = new System.Drawing.Point(8, 32);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(280, 128);
this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "PopupControlContainer demo";
//
// dropDownBtn
//
this.dropDownBtn.Image = ((System.Drawing.Bitmap)(resources.GetObject("dropDownBtn.Image")));
this.dropDownBtn.Location = new System.Drawing.Point(240, 96);
this.dropDownBtn.Name = "dropDownBtn";
this.dropDownBtn.Size = new System.Drawing.Size(26, 20);
this.dropDownBtn.TabIndex = 0;
this.dropDownBtn.Click += new System.EventHandler(this.dropDownBtn_Click);
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem2});
this.menuItem1.Text = "Help";
//
// menuItem2
//
this.menuItem2.Index = 0;
this.menuItem2.Text = "About Syncfusion";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.sourceTextBox,
this.label1,
this.popupControlContainer1,
this.groupBox1});
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "Custom Popups Dialog";
this.popupControlContainer1.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
[STAThread]
public static void Main()
{
Application.Run(new Form1());
}
#region OpenClosePopup
private void textBoxPopupParent_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
// Using this unconventional if statement syntax to avoid "and" symbol (documentation restriction, please ignore).
// If user pressed key down, then show the popup.
if(e.Alt)
if(e.KeyCode == Keys.Down)
if(!this.popupControlContainer1.IsShowing())
{
// Let the popup align around the source textBox.
this.popupControlContainer1.ParentControl = this.sourceTextBox;
// Passing Point.Empty will align it automatically around the above ParentControl.
this.popupControlContainer1.ShowPopup(Point.Empty);
e.Handled = true;
}
// Escape should close the popup.
if(e.KeyCode == Keys.Escape)
if(this.popupControlContainer1.IsShowing())
this.popupControlContainer1.HidePopup(PopupCloseType.Canceled);
}
private void OK_Click(object sender, System.EventArgs e)
{
this.popupControlContainer1.HidePopup(PopupCloseType.Done);
}
private void cancelButton_Click(object sender, System.EventArgs e)
{
this.popupControlContainer1.HidePopup(PopupCloseType.Canceled);
}
#endregion OpenClosePopup
#region PopupEvents
private void popupControlContainer1_BeforePopup(object sender, System.ComponentModel.CancelEventArgs e)
{
// Set the text to be edited with the text in the form text box.
this.popupTextBox.Text = this.sourceTextBox.Text;
}
private void popupControlContainer1_Popup(object sender, System.EventArgs e)
{
// Set the focus on the text box inside the popup after it is open.
this.popupTextBox.Focus();
this.popupTextBox.SelectionStart = 0;
this.popupTextBox.SelectionLength = 0;
}
private void popupControlContainer1_CloseUp(object sender, Syncfusion.Windows.Forms.PopupClosedEventArgs args)
{
// Transfer data from the popup.
if(args.PopupCloseType == PopupCloseType.Done)
{
this.sourceTextBox.Text = this.popupTextBox.Text;
}
// Set focus back to textbox.
if(args.PopupCloseType == PopupCloseType.Done
|| args.PopupCloseType == PopupCloseType.Canceled)
this.sourceTextBox.Focus();
}
#endregion PopupEvents
// The PopupControlContainer's BeforePopup event handler
private void popupControlContainer1_BeforePopup(object sender, System.ComponentModel.CancelEventArgs e)
{
// Create a Popup, that can be resized.
// Make the popup host's border style resizable.
this.popupControlContainer1.PopupHost.FormBorderStyle = FormBorderStyle.SizableToolWindow;
this.popupControlContainer1.PopupHost.BackColor = this.BackColor;
// Necessary to set the host's client size every time, especially since the
// popup's Dock style is set to DockStyle.Fill.
if(!(this.popupControlContainer1.PopupHost.Size.Width >= 140))
this.popupControlContainer1.PopupHost.Size = new System.Drawing.Size(140, 150);
// So that the popup container will fill the entire popup host when resized.
this.popupControlContainer1.Dock = DockStyle.Fill;
}
// While the parent PopupControlContainer is showing, you might want to show another child
// PopupControlContainer. You can do so as follows:
// Set up parent-child relationship.
parentPopupControlContainer.CurrentPopupChild = childPopupControlContainer;
childPopupControlContainer.PopupParent = parentPopupControlContainer;
// Now show the child popup.
childPopupControlContainer.ShowPopup();
public bool EnableIntelliMouse
{
get
{
return imm != null and imm.Enabled;
}
set
{
if (value != EnableIntelliMouse)
{
if (imm == null)
{
imm = new IntelliMouseDragScroll(this, true);
imm.AllowScrolling = ScrollBars.Both;
imm.DragScroll += new IntelliMouseDragScrollEventHandler(IntelliMouseDragScrollEvent);
}
imm.Enabled = value;
}
}
}
void IntelliMouseDragScrollEvent(object sender, IntelliMouseDragScrollEventArgs e)
{
int dy = e.Dy;
int dx = e.Dx;
this.disableAutoScroll = true;
if (Math.Abs(dy) > Math.Abs(dx))
{
VScrollBar.SendScrollMessage(dy > 0 ? ScrollEventType.SmallIncrement : ScrollEventType.SmallDecrement);
}
else
{
HScrollBar.SendScrollMessage(dx > 0 ? ScrollEventType.SmallIncrement : ScrollEventType.SmallDecrement);
}
this.disableAutoScroll = false;
}
The ScrollersFrame's automatic initialization should suffice for most applications and you should explicitly set this property only when you want to override the default menu provider assignment.
// The following example demonstrates temporarily suspending exception caching when calling a base class version
// of a method.
protected override void OnMouseDown(MouseEventArgs e)
{
ExceptionManager.SuspendCatchExceptions();
try
{
base.OnMouseDown(e);
ExceptionManager.ResumeCatchExceptions();
}
catch (Exception ex)
{
ExceptionManager.ResumeCatchExceptions();
// Notify exception manager about the catched exception and
// give it a chance to optionally rethrow the exception if necessary
// (e.g. if this OnMouseDown was called from another class that
// wants to provide its own exception handling).
if (!ExceptionManager.RaiseExceptionCatched(this, ex))
throw ex;
// handle exception here
MessageBox.Show(ex.ToString());
}
}
// This code sample shows how exceptions are handled within the framework:
try
{
CurrentCell.Refresh();
}
catch (Exception ex)
{
TraceUtil.TraceExceptionCatched(ex);
if (!ExceptionManager.RaiseExceptionCatched(this, ex))
throw ex;
}
public class GridTextBox: RichTextBox
{
private GridTextBoxCell parent;
protected override void OnMouseWheel(MouseEventArgs e)
{
parent.Grid.ProcessMouseWheel(e);
}
}
protected virtual void OnHScroll(object sender, ScrollEventArgs se)
{
try
{
IScrollBarFrame sbf = GetScrollBarFrameOfComponent(this);
if (sbf != null && !sbf.IsActive(this, ScrollBars.Horizontal))
return;
}}
private void ShowFolderBrowserDialog()
{
// Create the FolderBrowser component:
this.folderBrowser1 = new Syncfusion.Windows.Forms.FolderBrowser();
// Initialize the FolderBrowser component:
this.folderBrowser1.Description = "Syncfusion FolderBrowser";
this.folderBrowser1.StartLocation = Syncfusion.Windows.Forms.FolderBrowserFolder.Desktop;
this.folderBrowser1.Style =
( Syncfusion.Windows.Forms.FolderBrowserStyles.RestrictToFilesystem |
Syncfusion.Windows.Forms.FolderBrowserStyles.BrowseForComputer );
// Provide a handler for the FolderBrowserCallback validation event:
this.folderBrowser1.FolderBrowserCallback += new Syncfusion.Windows.Forms.FolderBrowserCallbackEventHandler(this.folderBrowser1_BrowseCallback);
// Display the folderbrowser dialog:
if (this.folderBrowser1.ShowDialog() == DialogResult.OK)
this.selectedFolder = this.folderBrowser1.DirectoryPath;
}
// Event handler for the FolderBrowser.FolderBrowserCallback validation event.
// This handler is functionally equivalent of the Win32 BrowseCallbackProc callback function:
private void folderBrowser1_BrowseCallback(object sender, Syncfusion.Windows.Forms.FolderBrowserCallbackEventArgs e)
{
this.label1.Text = String.Format("Event: {0}, Path: {1}", e.FolderBrowserMessage, e.Path);
if (e.FolderBrowserMessage == FolderBrowserMessage.ValidateFailed)
{
e.Dismiss = e.Path != "NONE";
}
}
public override void DropDownContainerShowedDropDown(object sender, EventArgs e)
{
this.ListControlPart.grid.MouseControllerDispatcher.TrackMouse =
this.ListControlPart.grid.RangeInfoToRectangle(GridRangeInfo.Rows(
this.ListControlPart.grid.TopRowIndex,
this.ListControlPart.grid.RowCount));
}
resizeCellsController = new GridResizeCellsMouseController(this);
MouseControllerDispatcher.Add(resizeCellsController);
See ScrollControl.MouseControllerDispatcher property.
This
To use this component, just create it passing the PropertyGrid in the constructor. The context menu will then start appearing for that PropertyGrid. There is no design-time support for this component.
public Form1()
{
InitializeComponent();
this.tabControl1.Bar.DraggingTab += new TabMovedEventHandler(Bar_DraggingTab);
}
private void Bar_DraggingTab(object sender, TabMovedEventArgs e)
{
Console.WriteLine("Bar_DraggingTab {0}, {1}", e.Tab, e.DestTab);
e.Cancel = true; // Do not allow dragging the tab
}
protected virtual void OnHScroll(object sender, ScrollEventArgs se)
{
try
{
IScrollBarFrame sbf = GetScrollBarFrameOfComponent(this);
if (sbf != null && !sbf.IsActive(this, ScrollBars.Horizontal))
return;
}}
public class NewWorkbookFile : BasicAction
{
int windowCount = 0;
WorkbookModel workbook;
public override void InvokeAction(object sender, EventArgs e)
{
windowCount++;
workbook = new WorkbookModel("Workbook");
GridModel sheet1 = new GridModel();
SampleGrid.SetupGridModel(sheet1);
GridModel sheet2 = new GridModel();
SampleGrid.SetupGridModel(sheet2);
workbook.Worksheets.Add(new WorksheetModel(workbook, "Sheet 1", sheet1));
workbook.Worksheets.Add(new WorksheetModel(workbook, "Sheet 2", sheet2));
WorkbookForm doc = new WorkbookForm(workbook);
doc.Text = workbook.Name + windowCount;
doc.MdiParent = MainWindow;
doc.Show();
}
}
public class NewWorkbookFile : BasicAction
{
int windowCount = 0;
WorkbookModel workbook;
public override void InvokeAction(object sender, EventArgs e)
{
windowCount++;
workbook = new WorkbookModel("Workbook");
GridModel sheet1 = new GridModel();
SampleGrid.SetupGridModel(sheet1);
GridModel sheet2 = new GridModel();
SampleGrid.SetupGridModel(sheet2);
workbook.Worksheets.Add(new WorksheetModel(workbook, "Sheet 1", sheet1));
workbook.Worksheets.Add(new WorksheetModel(workbook, "Sheet 2", sheet2));
WorkbookForm doc = new WorkbookForm(workbook);
doc.Text = workbook.Name + windowCount;
doc.MdiParent = MainWindow;
doc.Show();
}
}
// interface IOperationFeedbackProvider
public event OperationFeedbackEventHandler OperationFeedback;
Stack feedbackStack = new Stack();
void IOperationFeedbackProvider.RaiseOperationFeedbackEvent(OperationFeedbackEventArgs e)
{
if (OperationFeedback != null)
OperationFeedback(this, e);
}
Stack IOperationFeedbackProvider.FeedbackStack
{
get { return feedbackStack; }
}
When you implement an operation that you want to be cancellable or where
you want to show feedback (e.g. display percentage in status bar) you
do this by creating an OperationFeedback object inside a using statement.
using (OperationFeedback op = new OperationFeedback(this))
{
op.Name = "Cell";
op.Description = "Command Description";
op.AllowCancel = true;
op.AllowNestedProgress = true;
op.AllowNestedFeedback = false;
while (n++ != 100)
{
if (op.ShouldCancel())
return;
op.PercentComplete = n;
}
}
It is also supported in nest operations in case your method calls other
routines that also use OperationFeedback. AllowNestedProgress will disable
OperationFeedback and OperationProgress / ShouldCancel in nested routines.
AllowNestedFeedback will simply prohibit changing the description. But
the object will still fire OperationProgress events.
public static DialogResult ShowGridBaseStylesMapDialog(object instance, string propertyName)
{
GridBaseStyleCollectionEditor ce = new GridBaseStyleCollectionEditor(typeof(ArrayList));
WindowsFormsEditorServiceContainer esc = new WindowsFormsEditorServiceContainer(null);
PropertyDescriptor pd = TypeDescriptor.GetProperties(instance)[propertyName];
TypeDescriptorContext tdc = new TypeDescriptorContext(instance, pd);
tdc.ServiceProvider = esc;
object v = ce.EditValue(tdc, esc, ((ICloneable) pd.GetValue(instance)).Clone());
if (esc.DialogResult == DialogResult.OK)
{
pd.SetValue(instance, v);
}
return esc.DialogResult;
}
public static DialogResult ShowGridBaseStylesMapDialog(object instance, string propertyName)
{
GridBaseStyleCollectionEditor ce = new GridBaseStyleCollectionEditor(typeof(ArrayList));
WindowsFormsEditorServiceContainer esc = new WindowsFormsEditorServiceContainer(null);
PropertyDescriptor pd = TypeDescriptor.GetProperties(instance)[propertyName];
TypeDescriptorContext tdc = new TypeDescriptorContext(instance, pd);
tdc.ServiceProvider = esc;
object v = ce.EditValue(tdc, esc, ((ICloneable) pd.GetValue(instance)).Clone());
if (esc.DialogResult == DialogResult.OK)
{
pd.SetValue(instance, v);
}
return esc.DialogResult;
}
public override StyleInfoSubObjectIdentity CreateSubObjectIdentity(StyleInfoProperty sip)
{
return new FormVisualStyleInfoSubObjectIdentity(this, sip);
}
this.Style.TitleBar.AllowRichText = true;
// Set rich text for the Form.Text property.
this.Text = "{\\rtf\\ansi \\b Form1}";
this.Style.TitleBar.Font = new Font("Segoe UI", 15, FontStyle.Bold);
public override StyleInfoSubObjectIdentity CreateSubObjectIdentity(StyleInfoProperty sip)
{
return new GridStyleInfoSubObjectIdentity(this, sip);
}
//Loads a Button control to the title bar of the form.
TitleBarTextControl = new Button();
//Sets the text for the TitleBarTextControl.
TitleBarTextControl.Text = "Control1";
//Call BeginUpdate() to ensure the form is painted only once.
this.BeginUpdate();
//Change the appearance of the form.
this.Style.TitleBar.ForeColor = Color.Red;
this.Style.TitleBar.BackColor = Color.SkyBlue;
//Call EndUpdate() when finish changing the appearance of the form.
this.EndUpdate();
//Call BeginUpdate() to ensure the form is painted only once.
this.BeginUpdate();
//Change the appearance of the form.
this.Style.TitleBar.ForeColor = Color.Red;
this.Style.TitleBar.BackColor = Color.SkyBlue;
//Call EndUpdate() when finish changing the appearance of the form.
this.EndUpdate();
FontHelper.FontFamily = new FontFamily("Times New Roman");
list.Move(2, 4, 2);
This is a memory efficient way to represent a table where values can remain empty. Only rows
that actually contain data will allocate an
When you access data that are out of range, an empty () object will be returned. If you set data that are out of range, an exception will be thrown. If you set data for a row that is empty, the row will be allocated before the value is stored.
SFTable provides methods that let you insert, remove or rearrange columns or rows in the table.
SFTable array = new SFTable();
array.RowCount = 5;
array.ColCount = 1;
array[0,0] = 0;
array[1,0] = 1;
array[2,0] = 2;
array[3,0] = 3;
array.MoveRows(0, 2, 3);
// results in new order: 2, 0, 1, 3
SFTable array = new SFTable();
array.ColCount = 5;
array.RowCount = 1;
array[0,0] = 0;
array[0,1] = 1;
array[0,2] = 2;
array[0,3] = 3;
array.MoveCols(0, 2, 3);
// results in new order: 2, 0, 1, 3
SFArrayList array = new SFArrayList();
array[0] = 0;
array[1] = 1;
array[2] = 2;
array[3] = 3;
array.MoveRange(0, 2, 3);
// results in new order: 2, 0, 1, 3
SFArrayList array = new SFArrayList();
array[0] = 0;
array[1] = 1;
array[2] = 2;
array[3] = 3;
array.RemoveRange(1, 2);
// results in new order: 0, 3
SFArrayList array = new SFArrayList();
array[0] = 0;
array[1] = 1;
array[2] = 2;
array[3] = 3;
array.InsertRange(1, 2);
// results in new order: 0, null, null, 2, 3
if (TraceUtil.IsCalledFrom(typeof(Form1).GetMethod("Form1_Load", BindingFlags.NonPublic|BindingFlags.Instance)))
Debugger.Break();
private void OnTimerElapsed(object source, ElapsedEventArgs e)
{
TraceUtil.TraceCalledFromIf(Switches.Timers.TraceVerbose, 3);
}
private void OnTimerElapsed(object source, ElapsedEventArgs e)
{
TraceUtil.TraceCurrentMethodInfoIf(Switches.Timers.TraceVerbose);
}
private void button1_Click(object sender, System.EventArgs e)
{
int rows = (int) this.numericUpDown1.Value;
this.gridControl1.theData = new VirtGrid.VirtData(rows, 20);
this.gridControl1.Refresh();
using (Syncfusion.Diagnostics.MeasureTime.Measure("gridControl1.TopRowIndex = 500000"))
{
this.gridControl1.TopRowIndex = 5000000;
}
MessageBox.Show(Syncfusion.Diagnostics.MeasureTime.DumpTimes());
}
if (Environment.Version.Major >= 2)
ActiveXSnapshot.ForceWmPaintInPrintWindow = true;
This color list will be used to specify the
The first entry in this list will be the same as the
Note that this list is Read-only.
Also, you do not have to use this method if your images will never be drawn clipped (in that case just use ImageList.Draw).
standard.Font.Facename = "Helvetica";
model[1, 3].Font.Bold = true;
string faceName = model[1, 3].Font.Facename; // any cell inherits standard style
Console.WriteLIne(faceName); // will output "Helvetica"
Console.WriteLIne(model[1, 3].Font.Bold); // will output "true"
Console.WriteLIne(model[1, 3].Font.HasFaceName); // will output "False"
public override StyleInfoSubObjectIdentity CreateSubObjectIdentity(StyleInfoProperty sip)
{
return new GridStyleInfoSubObjectIdentity(this, sip);
}
XmlSerializer imageHolderSerializer = new XmlSerializer(typeof(object), new Type[] { typeof(ImageHolder) });
GridStyleInfoStore.RegisterXmlSerializer(typeof(ImageHolder), imageHolderSerializer);
standard.Font.Facename = "Helvetica";
model[1, 3].Font.Bold = true;
string faceName = model[1, 3].Font.Facename; // any cell inherits standard style
Console.WriteLIne(faceName); // will output "Helvetica"
Console.WriteLIne(model[1, 3].Font.Bold); // will output "true"
Console.WriteLIne(model[1, 3].Font.HasFaceName); // will output "False"
// To Save
AppStateSerializer serializer = new AppStateSerializer(SerializeMode.XMLFile, "myfile");
serializer.SerializeObject("MyLabel", mydata);
serializer.PersistNow();
// To Load
AppStateSerializer serializer = new AppStateSerializer(SerializeMode.XMLFile, "myfile");
object loadedObj = serializer.DeserializeObject("MyLabel");
if(loadedObj != null && loadedObj is MyData)
{
MyData myData = (MyData)loadedObj;
}
// To Save
AppStateSerializer.GetSingleton().SerializeObject("MyLabel", mydata, true);
// To Load
object loadedObj = AppStateSerializer.GetSingleton().DeserializeObject("MyLabel");
static MyType()
{
AppStateSerializer.SetBindingInfo("MyNameSpace.MyType", typeof(MyType).Assembly);
}
public Form1()
{
// To make the singleton use an XML file:
AppStateSerializer.InitializeSingleton(SerializeMode.XMLFile, "GlobalState");
InitializeComponent();
}