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
This enumeration has a FlagsAttribute that allows a combination of its member values.
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
// 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;
}
// 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);
' Create the CurrencyTextBox
Me.currencyTextBox1 = New CurrencyTextBox
' Set the initial value
Me.currencyTextBox1.Text = "$1.00"
' Set the clipmode
Me.currencyTextBox1.ClipMode = CurrencyClipModes.IncludeFormatting
' Set formatting properties
Me.currencyTextBox1.CurrencyDecimalDigits = 2
Me.currencyTextBox1.CurrencyDecimalSeparator = "."
Me.currencyTextBox1.CurrencyGroupSeparator = ","
Me.currencyTextBox1.CurrencyGroupSizes = New Integer() {3}
Me.currencyTextBox1.CurrencyNegativePattern = 1
Me.currencyTextBox1.CurrencyNumberDigits = 27
Me.currencyTextBox1.CurrencyPositivePattern = 0
Me.currencyTextBox1.CurrencySymbol = "$"
Me.currencyTextBox1.ForeColor = System.Drawing.Color.Black
Me.currencyTextBox1.NegativeColor = System.Drawing.Color.Red
Me.currencyTextBox1.NegativeSign = "-"
Me.currencyTextBox1.PositiveColor = System.Drawing.Color.Black
Me.currencyTextBox1.Size = New System.Drawing.Size(256, 20)
Me.currencyTextBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
' Add the CurrencyTextBox control to the form
Me.Controls.Add(Me.currencyTextBox1)
Console.WriteLine("ValidationError in currencyTextBox1 InvalidText" + e.InvalidText);
Console.WriteLine("ValidationError in currencyTextBox1 StartPosition" + e.StartPosition );
Console.WriteLine(("ValidationError in currencyTextBox1 InvalidText" + e.InvalidText))
Console.WriteLine(("ValidationError in currencyTextBox1 StartPosition" + e.StartPosition))
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).
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
Public Sub New()
MyBase.New()
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 wouldn't close sometimes, after dropping down this popup!
Me.popupControlContainer1.Parent.Controls.Remove(Me.popupControlContainer1)
End Sub
Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.popupControlContainer1 = New Syncfusion.Windows.Forms.PopupControlContainer()
Me.cancel = New System.Windows.Forms.Button()
Me.OK = New System.Windows.Forms.Button()
Me.popupTextBox = New System.Windows.Forms.TextBox()
Me.label1 = New System.Windows.Forms.Label()
Me.sourceTextBox = New System.Windows.Forms.TextBox()
Me.groupBox1 = New System.Windows.Forms.GroupBox()
Me.dropDownBtn = New System.Windows.Forms.Button()
Me.mainMenu1 = New System.Windows.Forms.MainMenu()
Me.menuItem1 = New System.Windows.Forms.MenuItem()
Me.menuItem2 = New System.Windows.Forms.MenuItem()
Me.popupControlContainer1.SuspendLayout()
Me.groupBox1.SuspendLayout()
Me.SuspendLayout()
'
' popupControlContainer1
'
Me.popupControlContainer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.popupControlContainer1.Controls.AddRange(New System.Windows.Forms.Control() {Me.cancel, Me.OK, Me.popupTextBox})
Me.popupControlContainer1.Location = New System.Drawing.Point(80, 128)
Me.popupControlContainer1.Name = "popupControlContainer1"
Me.popupControlContainer1.Size = New System.Drawing.Size(120, 128)
Me.popupControlContainer1.TabIndex = 0
Me.popupControlContainer1.Visible = False
AddHandler Me.popupControlContainer1.Popup, New System.EventHandler(AddressOf popupControlContainer1_Popup)
AddHandler Me.popupControlContainer1.CloseUp, New Syncfusion.Windows.Forms.PopupClosedEventHandler(AddressOf popupControlContainer1_CloseUp)
AddHandler Me.popupControlContainer1.BeforePopup, New System.ComponentModel.CancelEventHandler(AddressOf popupControlContainer1_BeforePopup)
'
' cancel
'
Me.cancel.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.cancel.Location = New System.Drawing.Point(64, 96)
Me.cancel.Name = "cancel"
Me.cancel.Size = New System.Drawing.Size(48, 24)
Me.cancel.TabIndex = 2
Me.cancel.Text = "Cancel"
AddHandler Me.cancel.Click, New System.EventHandler(AddressOf cancelButton_Click)
'
' OK
'
Me.OK.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.OK.Location = New System.Drawing.Point(8, 96)
Me.OK.Name = "OK"
Me.OK.Size = New System.Drawing.Size(48, 24)
Me.OK.TabIndex = 1
Me.OK.Text = "OK"
AddHandler Me.OK.Click, New System.EventHandler(AddressOf OK_Click)
'
' popupTextBox
'
Me.popupTextBox.Multiline = True
Me.popupTextBox.Name = "popupTextBox"
Me.popupTextBox.Size = New System.Drawing.Size(118, 90)
Me.popupTextBox.TabIndex = 0
Me.popupTextBox.Text = ""
'
' label1
'
Me.label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.label1.Location = New System.Drawing.Point(16, 56)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(256, 64)
Me.label1.TabIndex = 1
Me.label1.Text = ("Associate a PopupControlContainer with this TextBox. And also transfer data back " + "and forth between the popup and the TextBox.")
'
' sourceTextBox
'
Me.sourceTextBox.Location = New System.Drawing.Point(40, 128)
Me.sourceTextBox.Name = "sourceTextBox"
Me.sourceTextBox.Size = New System.Drawing.Size(200, 20)
Me.sourceTextBox.TabIndex = 2
Me.sourceTextBox.Text = "Alt+DownArrow for popup"
AddHandler Me.sourceTextBox.KeyDown, New System.Windows.Forms.KeyEventHandler(AddressOf textBoxPopupParent_KeyDown)
'
' groupBox1
'
Me.groupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.dropDownBtn})
Me.groupBox1.Location = New System.Drawing.Point(8, 32)
Me.groupBox1.Name = "groupBox1"
Me.groupBox1.Size = New System.Drawing.Size(280, 128)
Me.groupBox1.TabIndex = 3
Me.groupBox1.TabStop = False
Me.groupBox1.Text = "PopupControlContainer demo"
'
' dropDownBtn
'
Me.dropDownBtn.Image = CType(resources.GetObject("dropDownBtn.Image"), System.Drawing.Bitmap)
Me.dropDownBtn.Location = New System.Drawing.Point(240, 96)
Me.dropDownBtn.Name = "dropDownBtn"
Me.dropDownBtn.Size = New System.Drawing.Size(26, 20)
Me.dropDownBtn.TabIndex = 0
AddHandler Me.dropDownBtn.Click, New System.EventHandler(AddressOf dropDownBtn_Click)
'
' mainMenu1
'
Me.mainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuItem1})
'
' menuItem1
'
Me.menuItem1.Index = 0
Me.menuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.menuItem2})
Me.menuItem1.Text = "Help"
'
' menuItem2
'
Me.menuItem2.Index = 0
Me.menuItem2.Text = "About Syncfusion"
AddHandler Me.menuItem2.Click, New System.EventHandler(AddressOf menuItem2_Click)
'
' Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.sourceTextBox, Me.label1, Me.popupControlContainer1, Me.groupBox1})
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Menu = Me.mainMenu1
Me.Name = "Form1"
Me.Text = "Custom Popups Dialog"
Me.popupControlContainer1.ResumeLayout(False)
Me.groupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
Private Sub textBoxPopupParent_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
' Using this unconventional if statement syntax to avoid "and" symbol (documentation restriction, please ignore).
' If user pressed key down, then show the popup.
' Escape should close the popup.
If e.Alt Then
If (e.KeyCode = Keys.Down) Then
If Not (Me.popupControlContainer1.IsShowing) Then
' Let the popup align around the source textBox.
Me.popupControlContainer1.ParentControl = Me.sourceTextBox
' Passing Point.Empty will align it automatically around the above ParentControl.
Me.popupControlContainer1.ShowPopup(Point.Empty)
e.Handled = True
End If
End If
End If
If (e.KeyCode = Keys.Escape) Then
If Me.popupControlContainer1.IsShowing Then
Me.popupControlContainer1.HidePopup(PopupCloseType.Canceled)
End If
End If
End Sub
Private Sub OK_Click(ByVal sender As Object, ByVal e As EventArgs)
Me.popupControlContainer1.HidePopup(PopupCloseType.Done)
End Sub
Private Sub cancelButton_Click(ByVal sender As Object, ByVal e As EventArgs)
Me.popupControlContainer1.HidePopup(PopupCloseType.Canceled)
End Sub
Private Sub popupControlContainer1_BeforePopup(ByVal sender As Object, ByVal e As CancelEventArgs)
' Set the text to be edited with the text in the form text box.
Me.popupTextBox.Text = Me.sourceTextBox.Text
End Sub
Private Sub popupControlContainer1_Popup(ByVal sender As Object, ByVal e As EventArgs)
' Set the focus on the text box inside the popup after its open.
Me.popupTextBox.Focus()
Me.popupTextBox.SelectionStart = 0
Me.popupTextBox.SelectionLength = 0
End Sub
Private Sub popupControlContainer1_CloseUp(ByVal sender As Object, ByVal args As PopupClosedEventArgs)
' Transfer data from the popup.
' Set focus back to textbox.
If (args.PopupCloseType = PopupCloseType.Done) Then
Me.sourceTextBox.Text = Me.popupTextBox.Text
End If
If ((args.PopupCloseType = PopupCloseType.Done) _
OrElse (args.PopupCloseType = PopupCloseType.Canceled)) Then
Me.sourceTextBox.Focus()
End If
End Sub
// 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;
}
' The PopupControlContainer's BeforePopup event handler
Private Sub popupControlContainer1_BeforePopup(ByVal sender As Object, ByVal e As CancelEventArgs)
' Create a popup that can be resized.
' Make the popup host's border style resizable.
Me.popupControlContainer1.PopupHost.FormBorderStyle = FormBorderStyle.SizableToolWindow
Me.popupControlContainer1.PopupHost.BackColor = Me.BackColor
' Necessary to set the host's client size every time, especially since the
' popup's dock style is set to DockStyle.Fill.
' So that the popup container will fill the entire popup host when resized.
If Not ((Me.popupControlContainer1.PopupHost.Size.Width >= 140)) Then
Me.popupControlContainer1.PopupHost.Size = New System.Drawing.Size(140, 150)
End If
Me.popupControlContainer1.Dock = DockStyle.Fill
End Sub
// 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();
' 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()
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
private void InitializeGroupBar()
{
// Create the GroupBar control.
this.gbOutlook = new Syncfusion.Windows.Forms.Tools.GroupBar();
// Create and initialize the GroupBarItems that belong to this GroupBar.
this.gbiPersonal = new Syncfusion.Windows.Forms.Tools.GroupBarItem();
// Assign the gvcPersonal client control to this GroupBarItem.
this.gbiPersonal.Client = this.gvcPersonal;
this.gbiPersonal.Text = "Personal";
this.gbiWork = new Syncfusion.Windows.Forms.Tools.GroupBarItem();
// Assign the gvcWork client control to this GroupBarItem.
this.gbiWork.Client = this.gvcWork;
this.gbiWork.Text = "Work";
// Add the GroupBarItems to the GroupBar.
this.gbOutlook.GroupBarItems.Add(this.gbiPersonal);
this.gbOutlook.GroupBarItems.Add(this.gbiWork);
// Set the GroupBar's initially selected index.
this.gbOutlook.SelectedItem = 1;
}
Private Sub InitializeGroupBar()
' Create the GroupBar control.
Me.gbOutlook = New Syncfusion.Windows.Forms.Tools.GroupBar()
' Create and initialize the GroupBarItems that belong to this GroupBar.
Me.gbiPersonal = New Syncfusion.Windows.Forms.Tools.GroupBarItem()
' Assign the gvcPersonal client control to this GroupBarItem.
Me.gbiPersonal.Client = Me.gvcPersonal
Me.gbiPersonal.Text = "Personal"
Me.gbiWork = New Syncfusion.Windows.Forms.Tools.GroupBarItem()
' Assign the gvcWork client control to this GroupBarItem.
Me.gbiWork.Client = Me.gvcWork
Me.gbiWork.Text = "Work"
' Add the GroupBarItems to the GroupBar.
Me.gbOutlook.GroupBarItems.Add(Me.gbiPersonal)
Me.gbOutlook.GroupBarItems.Add(Me.gbiWork)
' Set the GroupBar's initially selected index.
Me.gbOutlook.SelectedItem = 1
End SubWhen 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
private void InitializeGroupView()
{
// Create the GroupView control.
this.gvcWinForms = new Syncfusion.Windows.Forms.Tools.GroupView();
// Set the large and small ImageLists.
this.gvcWinForms.LargeImageList = this.ilGroupBarLarge;
this.gvcWinForms.SmallImageList = this.ilGroupBarSmall;
// Set the GroupView properties to display as a VS.NET tool box type window.
this.gvcWinForms.SmallImageView = true;
this.gvcWinForms.HighlightText = true;
this.gvcWinForms.ButtonView = true;
this.gvcWinForms.FlowView = false;
this.gvcWinForms.FlatLook = false;
this.gvcWinForms.TextWrap = false;
this.gvcWinForms.ImageSpacing = 2;
this.gvcWinForms.ItemXSpacing = 8;
this.gvcWinForms.ItemYSpacing = 1;
this.gvcWinForms.BackColor = SystemColors.Control;
this.gvcWinForms.ForeColor = SystemColors.ControlText;
this.gvcWinForms.HighlightItemColor = SystemColors.Control;
this.gvcWinForms.SelectingItemColor = ControlPaint.Light(SystemColors.ControlLight);
this.gvcWinForms.SelectedItemColor = ControlPaint.Light(SystemColors.ControlLight);
this.gvcWinForms.SelectedHighlightItemColor = SystemColors.Control;
this.gvcWinForms.SelectingTextColor = SystemColors.ControlText;
this.gvcWinForms.SelectedHighlightTextColor = SystemColors.ControlText;
// Create and add the GroupViewItem objects.
this.gvcWinForms.GroupViewItems.AddRange(
new Syncfusion.Windows.Forms.Tools.GroupViewItem[] {
new Syncfusion.Windows.Forms.Tools.GroupViewItem("Pointer", 11),
new Syncfusion.Windows.Forms.Tools.GroupViewItem("Label", 12),
new Syncfusion.Windows.Forms.Tools.GroupViewItem("LinkLabel", 13)});
// Provide a handler for the GroupView.GroupViewItemSelected event.
this.gvcWinForms.GroupViewItemSelected += new System.EventHandler(this.gvcWinForms_GroupViewItemSelected);
}
// GroupView.GroupViewItemSelected event handler.
private void gvcWinForms_GroupViewItemSelected(object sender, System.EventArgs e)
{
MessageBox.Show(String.Concat("Selected Item Index = ", this.gvcWinForms.SelectedItem.ToString()));
}
Private Sub InitializeGroupView()
' Create the GroupView control
Me.gvcWinForms = New Syncfusion.Windows.Forms.Tools.GroupView()
' Set the large and small ImageLists
Me.gvcWinForms.LargeImageList = Me.ilGroupBarLarge
Me.gvcWinForms.SmallImageList = Me.ilGroupBarSmall
' Set the GroupView properties to display as a VS.NET Toolbox type window
Me.gvcWinForms.SmallImageView = True
Me.gvcWinForms.HighlightText = True
Me.gvcWinForms.ButtonView = True
Me.gvcWinForms.FlowView = False
Me.gvcWinForms.FlatLook = False
Me.gvcWinForms.TextWrap = False
Me.gvcWinForms.ImageSpacing = 2
Me.gvcWinForms.ItemXSpacing = 8
Me.gvcWinForms.ItemYSpacing = 1
Me.gvcWinForms.BackColor = SystemColors.Control
Me.gvcWinForms.ForeColor = SystemColors.ControlText
Me.gvcWinForms.HighlightItemColor = SystemColors.Control
Me.gvcWinForms.SelectingItemColor = ControlPaint.Light(SystemColors.ControlLight)
Me.gvcWinForms.SelectedItemColor = ControlPaint.Light(SystemColors.ControlLight)
Me.gvcWinForms.SelectedHighlightItemColor = SystemColors.Control
Me.gvcWinForms.SelectingTextColor = SystemColors.ControlText
Me.gvcWinForms.SelectedHighlightTextColor = SystemColors.ControlText
' Create and add the GroupViewItem objects.
Me.gvcWinForms.GroupViewItems.AddRange(New Syncfusion.Windows.Forms.Tools.GroupViewItem() {New Syncfusion.Windows.Forms.Tools.GroupViewItem("Pointer", 11), New Syncfusion.Windows.Forms.Tools.GroupViewItem("Label", 12), New Syncfusion.Windows.Forms.Tools.GroupViewItem("LinkLabel", 13)})
' Handle the GroupView.GroupViewItemSelected event.
AddHandler Me.gvcWinForms.GroupViewItemSelected, New System.EventHandler(AddressOf gvcWinForms_GroupViewItemSelected)
End Sub
' GroupView.GroupViewItemSelected event handler.
Private Sub gvcWinForms_GroupViewItemSelected(ByVal sender As Object, ByVal e As System.EventArgs)
MessageBox.Show([String].Concat("Selected Item Index = ", Me.gvcWinForms.SelectedItem.ToString()))
End Sub 'gvcWinForms_GroupViewItemSelected
// Binding a control to the CardLayout 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 CardLayout manager programmatically.
Me.borderLayout1 = New BorderLayout()
Me.borderLayout1.ContainerControl = Me
' Set the border-position of the button.
Me.borderLayout1.SetPosition(Me.btnNorth, BorderPosition.North)
Me.borderLayout1.SetPosition(Me.btnSouth, BorderPosition.South)
Me.borderLayout1.SetPosition(Me.btnCenter, BorderPosition.Center)
Me.borderLayout1.SetPosition(Me.btnEast, BorderPosition.East)
Me.borderLayout1.SetPosition(Me.btnWest, BorderPosition.West)
// Binding a Control to the CardLayout 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 CardLayout manager programmatically.
Me.cardLayout1 = New CardLayout
' Set the target control; all the child controls of this target control are
' automatically registered as children with the manager and get default card names.
Me.cardLayout1.ContainerControl = Me.panel1
' Set custom card names to replace default card names.
Me.cardLayout1.SetCardName(Me.label1, "MyCard1")
' To select a card manually, use the SelectedCard property.
Me.cardLayout1.SelectedCard = "MyCard1"
' Or move through the cards like this:
Me.cardLayout1.Next
Me.cardLayout1.Previous
// Binding a control to the FlowLayout 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 flowLayout 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 FlowLayoutConstraints 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;
' Binding a control to the FlowLayout manager programmatically:
Me.flowLayout1 = New FlowLayout
' Set the target control; all the child controls of this target control are
' automatically registered as children with the manager:
Me.flowLayout1.ContainerControl = Me.panel1
' Set some properties on the flowLayout manager:
Me.flowLayout1.HGap = 20
Me.flowLayout1.Alignment = FlowAlignment.Near
' You can ignore one or more child controls from being laid out, like this (the first argument for FlowLayoutConstraints should be False).
' This will have the same effect as calling RemoveLayoutComponent:
Me.flowLayout1.SetConstraints(Me.label10, New FlowLayoutConstraints(False, HorzFlowAlign.Center, 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;
// Binding a control to the GridBagLayout 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 GridBagLayout manager programmatically:
Me.gridBagLayout1 = New GridBagLayout
' Set the target control; all the child controls of this target control are
' automatically registered as children with the manager:
Me.gridBagLayout1.ContainerControl = Me.panel1
Me.gridBagLayout1.SetConstraints(Me.button1, New GridBagConstraints(0, 0, 3, 1, 1, 0.2, AnchorTypes.Center, FillType.Both, New Insets(0, 0, 0, 0), 0, 0, false))
Me.gridBagLayout1.SetConstraints(Me.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:
Me.gridBagLayout1.SetConstraints(Me.button3, GridBagConstraints.Empty)
' Modify an exisiting constraint:
Dim constraints1 As GridBagConstraints
constraints1 = Me.gridBagLayout1.GetConstraintsRef(Me.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 GridLayout 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 flowLayout 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;
' Binding a Control to the GridLayout manager programmatically:
Me.gridLayout1 = New Syncfusion.Windows.Forms.Tools.GridLayout
' Set the target control; all the child controls of this target control are
' automatically registered as children with the manager:
Me.gridLayout1.ContainerControl = Me.innerPanel
' Set some properties on the flowLayout manager:
Me.gridLayout1.Columns = 4
Me.gridLayout1.Rows = 5
Me.gridLayout1.HGap = 4
Me.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;
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;
}
}
}
Public Class MyRectangle
Inherits LayoutItemBase
Protected WithEvents parent As Control
Protected color As color
Protected [text] As String
Public Shared PrefSize As Size
'Fields
'Constructors
'Events
'Methods
Shared Sub New()
'Warning: Implementation not found
End Sub
Public Sub New(ByVal parent As Control, ByVal color As color, ByVal [text] As String)
MyBase.New()
Me.parent = parent
Me.color = color
Me.text = [text]
End Sub
Public Overrides ReadOnly Property MinimumSize() As Size
Get
Return MyRectangle.PrefSize
End Get
End Property
Public Overrides ReadOnly Property PreferredSize() As Size
Get
Return MyRectangle.PrefSize
End Get
End Property
Protected Overloads Overrides Sub OnBoundsChanged()
parent.Invalidate(New Rectangle(0, 0, Me.parent.Width, Me.parent.Height))
End Sub
Public Sub OnPaint(ByVal e As PaintEventArgs)
e.Graphics.FillRectangle(New SolidBrush(color), Me.Bounds)
Dim sf As StringFormat
sf = New StringFormat()
sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center
Dim r As RectangleF
r = New RectangleF(Me.Bounds.Left, Me.Bounds.Top, Me.Bounds.Width, Me.Bounds.Height)
e.Graphics.DrawString([text], Control.DefaultFont, SystemBrushes.ControlText, r, sf)
End Sub
End Class
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);
}
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.SuspendLayout()
' Current layout manager (Update every time you change the manager)
' Layout Component 1:
Me.myRect1 = New MyRectangle(Me.gridBagLayout1.ContainerControl, Color.FromArgb(133, 191, 117), "Paint Area 1")
Me.myRect1.Bounds = New Rectangle(10, 10, 80, 20)
Me.myRect1.Visible = True
' Layout Component 2:
Me.myRect2 = New MyRectangle(Me.gridBagLayout1.ContainerControl, Color.FromArgb(222, 100, 19), "Paint Area 2")
Me.myRect2.Bounds = New Rectangle(10, 40, 80, 20)
Me.myRect2.Visible = True
' Layout Component 3:
Me.myRect3 = New MyRectangle(Me.gridBagLayout1.ContainerControl, Color.FromArgb(196, 214, 233), "Paint Area 3")
Me.myRect3.Bounds = New Rectangle(10, 70, 80, 20)
Me.myRect3.Visible = True
' Sample GridBagConstraints:
Dim gbc1 As GridBagConstraints
gbc1 = New GridBagConstraints()
Dim gbc2 As GridBagConstraints
gbc2 = New GridBagConstraints()
Dim gbc3 As 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:
Me.gridBagLayout1.SetConstraints(Me.myRect1.ToControl, gbc1)
Me.gridBagLayout1.SetConstraints(Me.myRect2.ToControl, gbc2)
Me.gridBagLayout1.SetConstraints(Me.myRect3.ToControl, gbc3)
Me.ResumeLayout(True)
End Sub
// 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);
' InitializeComponent
' Create the Masked edit box control:
Me.maskedEditBox1 = New MaskedEditBox()
' Specifies if the prompt character can be entered:
Me.maskedEditBox1.AllowPrompt = False
' The mask string:
Me.maskedEditBox1.Mask = ">?<????????????"
' The max length is set based on the mask:
Me.maskedEditBox1.MaxLength = 13
' The clip mode specifies if the literals are included:
Me.maskedEditBox1.ClipMode = ClipModes.IncludeLiterals
' The date time format:
Me.maskedEditBox1.TimeSeparator = Microsoft.VisualBasic.ChrW(58)
Me.maskedEditBox1.DateSeparator = Microsoft.VisualBasic.ChrW(45)
' The number format:
Me.maskedEditBox1.DecimalSeparator = Microsoft.VisualBasic.ChrW(46)
Me.maskedEditBox1.ThousandSeparator = Microsoft.VisualBasic.ChrW(44)
' Add the MaskedEditBox control to the form:
Me.Controls.Add(Me.maskedEditBox1)
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
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;
protected virtual void OnHScroll(object sender, ScrollEventArgs se)
{
try
{
IScrollBarFrame sbf = GetScrollBarFrameOfComponent(this);
if (sbf != null && !sbf.IsActive(this, ScrollBars.Horizontal))
return;
...
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.
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 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);
}
}
// 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
Dim serializer As New AppStateSerializer(SerializeMode.XMLFile, "myfile")
serializer.SerializeObject("MyLabel", mydata)
serializer.PersistNow()
' To Load
Dim serializer As New AppStateSerializer(SerializeMode.XMLFile, "myfile")
Dim loadedObj As Object = serializer.DeserializeObject("MyLabel")
If TypeOf loadedObj Is MyData Then
Dim myData As MyData = CType(loadedObj, MyData)
End If
// To Save
AppStateSerializer.GetSingleton().SerializeObject("MyLabel", mydata, true);
// To Load
object loadedObj = AppStateSerializer.GetSingleton().DeserializeObject("MyLabel");
' To Save
AppStateSerializer.GetSingleton().SerializeObject("MyLabel", mydata, true)
' To Load
Dim loadedObj As Object = AppStateSerializer.GetSingleton().DeserializeObject("MyLabel")
static MyType()
{
AppStateSerializer.SetBindingInfo("MyNameSpace.MyType", typeof(MyType).Assembly);
}
'In type MyType:
Shared Sub New()
AppStateSerializer.SetBindingInfo("MyNameSpace.MyType", Type.GetType(MyType).Assembly)
End Sub
public Form1()
{
// To make the singleton use an XML file:
AppStateSerializer.InitializeSingleton(SerializeMode.XMLFile, "GlobalState");
InitializeComponent();
}
Public Sub New()
{
' To make the singleton use an XML file:
AppStateSerializer.InitializeSingleton(SerializeMode.XMLFile, "GlobalState")
InitializeComponent()
}
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"
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));
Me.autoAppend = New AutoAppend()
Me.autoAppend.SetAutoAppend(Me.comboBox1, New AutoAppendInfo(True, "HttpAddress", Me.comboBox1.Items, 30))
' To disassociate call this:
Me.autoAppend.SetAutoAppend(Me.comboBox1, New AutoAppendInfo(False, [String].Empty, Nothing, 30))
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";
}
}
Private Sub ShowFolderBrowserDialog()
' Create an instance of the FolderBrowser component:
Me.folderBrowser1 = New Syncfusion.Windows.Forms.FolderBrowser(Me.components)
' Set the descriptor text that will appear on the folder dialog:
Me.folderBrowser1.Description = "Syncfusion FolderBrowser"
' Specify the start location:
Me.folderBrowser1.StartLocation = Syncfusion.Windows.Forms.FolderBrowserFolder.Desktop
' Specify the styles for the folder browser dialog:
Me.folderBrowser1.Style = Syncfusion.Windows.Forms.FolderBrowserStyles.RestrictToFilesystem Or Syncfusion.Windows.Forms.FolderBrowserStyles.BrowseForComputer
' Provide a handler for the FolderBrowserCallback validation event:
AddHandler Me.folderBrowser1.FolderBrowserCallback, New Syncfusion.Windows.Forms.FolderBrowserCallbackEventHandler(AddressOf folderBrowser1_BrowseCallback)
' Show the folder browser dialog:
Try
If folderBrowser1.ShowDialog() = DialogResult.OK Then
Me.label1.Text = [String].Concat("Selection: ", folderBrowser1.DirectoryPath)
End If
Catch ex As Exception
Console.WriteLine(ex.ToString())
End Try
End Sub
' Event handler for the FolderBrowser.FolderBrowserCallback validation event.
' This handler is functionally equivalent of the Win32 BrowseCallbackProc callback function:
Private Sub folderBrowser1_BrowseCallback(ByVal sender As Object, ByVal e As FolderBrowserCallbackEventArgs)
Me.label1.Text = String.Format("Event: {0}, Path: {1}", e.FolderBrowserMessage, e.Path)
If (e.FolderBrowserMessage = FolderBrowserMessage.ValidateFailed) Then
e.Dismiss = (e.Path Is "NONE") = False
End If
End Sub
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();
}
}