+
+
+
+
+
+
+
+
+
+ public class GridTextBox: RichTextBox
+ {
+ private GridTextBoxCell parent;
+ protected override void OnMouseWheel(MouseEventArgs e)
+ {
+ parent.Grid.ProcessMouseWheel(e);
+ }
+ }
+
+
+ public static GridModel LoadSoap(Stream s)
+ {
+ try
+ {
+ AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(GridBaseAssembly.AssemblyResolver);
+ SoapFormatter b = new SoapFormatter();
+ b.AssemblyFormat = FormatterAssemblyStyle.Simple;
+ GridModel t = b.Deserialize(s) as GridModel;
+ t.Modified = false;
+ return t;
+ }
+ finally
+ {
+ AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(GridBaseAssembly.AssemblyResolver);
+ }
+ }
+
+
+
+ public static GridModel LoadSoap(Stream s)
+ {
+ try
+ {
+ AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(GridWindowsAssembly.AssemblyResolver);
+ SoapFormatter b = new SoapFormatter();
+ b.AssemblyFormat = FormatterAssemblyStyle.Simple;
+ GridModel t = b.Deserialize(s) as GridModel;
+ t.Modified = false;
+ return t;
+ }
+ finally
+ {
+ AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(GridWindowsAssembly.AssemblyResolver);
+ }
+ }
+
+
+ void gridControl1_CellClick(object sender, GridCellClickEventArgs e)
+ {
+ //Removes border margins from a given cell rectangle.
+ GridRangeInfo range = this.gridControl1.Model.CoveredRanges.FindRange(e.RowIndex, e.ColIndex);
+ Rectangle rect = this.gridControl1.RangeInfoToRectangle(range);
+ this.gridControl1.CurrentCell.Model.SubtractBorders(rect, style, true);
+ }
+
+
+ Private Sub gridControl1_CellClick(ByVal sender As Object, ByVal e As GridCellClickEventArgs)
+ 'Removes border margins from a given cell rectangle.
+ Dim range As GridRangeInfo = Me.gridControl1.Model.CoveredRanges.FindRange(e.RowIndex, e.ColIndex)
+ Dim rect As Rectangle = Me.gridControl1.RangeInfoToRectangle(range)
+ Me.gridControl1.CurrentCell.Model.SubtractBorders(rect, style, True)
+ End Sub
+
+
+ void gridControl1_CellClick(object sender, GridCellClickEventArgs e)
+ {
+ string text="GridControl";
+ this.gridControl1.CurrentCell.Model.SetActiveText(e.RowIndex, e.ColIndex, text);
+ }
+
+
+ Private Sub gridControl1_CellClick(ByVal sender As Object, ByVal e As GridCellClickEventArgs)
+ Dim text As String="Active Text"
+ Me.gridControl1.CurrentCell.Model.SetActiveText(e.RowIndex, e.ColIndex, text)
+ End Sub
+
+
+ //Scroll position based on the column index.
+ public override object GetEditState()
+ {
+ if (this.gridControl1.CurrentCell.IsEditing)
+ {
+ return new int[] { 0, this.gridControl1[this.gridControl1.CurrentCell.RowIndex,this.gridControl1.CurrentCell.ColIndex].Text.Length };
+ }
+ return null;
+ }
+
+
+ Public Overrides Function GetEditState() As Object
+ If Me.gridControl1.CurrentCell.IsEditing Then
+ Return New Integer(){ 0, Me.gridControl1(Me.gridControl1.CurrentCell.RowIndex, Me.gridControl1.CurrentCell.ColIndex).Text.Length }
+ End If
+ Return Nothing
+ End Function
+
+
+ public static void Draw3dFrame(Graphics g, int x0, int y0, int x1, int y1, int w, Color rgbTopLeft, Color rgbBottomRight)
+ {
+ Rectangle rc;
+ for (int i = 0; i != w; i++)
+ {
+ // Top
+ Brush brTL = new SolidBrush(rgbTopLeft);
+ rc = Rectangle.FromLTRB(x0, y0, x1, y0+1);
+ g.FillRectangle(brTL, rc);
+ // Left
+ rc = Rectangle.FromLTRB(x0, y0, x0+1, y1);
+ g.FillRectangle(brTL, rc);
+ brTL.Dispose();
+ Brush brBR = new SolidBrush(rgbBottomRight);
+ // Bottom
+ rc = Rectangle.FromLTRB(x0, y1, x1+1, y1+1);
+ g.FillRectangle(brBR, rc);
+ // Right
+ rc = Rectangle.FromLTRB(x1, y0, x1+1, y1);
+ g.FillRectangle(brBR, rc);
+ brBR.Dispose();
+ if (i != w-1)
+ {
+ x0++;
+ y0++;
+ x1--;
+ y1--;
+ }
+ }
+ }
+ protected override void OnDrawCellButtonBackground(GridCellButton button, Graphics g, Rectangle rect, ButtonState buttonState, GridStyleInfo style)
+ {
+ bool drawPressed = (buttonState & ButtonState.Pushed) != 0;
+ Color hilight = SystemColors.ControlLightLight;
+ Color shadow = SystemColors.ControlDarkDark;
+ if (!drawPressed)
+ {
+ GridPaint.Draw3dFrame(g, rect.Left, rect.Top, rect.Right-1, rect.Bottom-1, 1,
+ hilight, shadow);
+ }
+ else
+ {
+ Brush br = new SolidBrush(shadow);
+ g.FillRectangle(br, Rectangle.FromLTRB(rect.Left, rect.Bottom-1, rect.Right-1, rect.Bottom));
+ g.FillRectangle(br, Rectangle.FromLTRB(rect.Right-1, rect.Top, rect.Right, rect.Bottom));
+ br.Dispose();
+ }
+ }
+
+
+ Public Shared Sub Draw3dFrame(g As Graphics, x0 As Integer, y0 As Integer, x1 As Integer, y1 As Integer, w As Integer, rgbTopLeft As Color, rgbBottomRight As Color)
+ Dim rc As Rectangle
+ Dim i As Integer
+ While i <> w
+ ' Top
+ Dim brTL = New SolidBrush(rgbTopLeft)
+ rc = Rectangle.FromLTRB(x0, y0, x1, y0 + 1)
+ g.FillRectangle(brTL, rc)
+ ' Left
+ rc = Rectangle.FromLTRB(x0, y0, x0 + 1, y1)
+ g.FillRectangle(brTL, rc)
+ brTL.Dispose()
+ Dim brBR = New SolidBrush(rgbBottomRight)
+ ' Bottom
+ rc = Rectangle.FromLTRB(x0, y1, x1 + 1, y1 + 1)
+ g.FillRectangle(brBR, rc)
+ ' Right
+ rc = Rectangle.FromLTRB(x1, y0, x1 + 1, y1)
+ g.FillRectangle(brBR, rc)
+ brBR.Dispose()
+ If i <> w - 1 Then
+ x0 += 1
+ y0 += 1
+ x1 -= 1
+ y1 -= 1
+ End If
+ i += 1
+ End While
+ End Sub 'Draw3dFrame
+
+ Protected Overrides Sub OnDrawCellButtonBackground(button As GridCellButton, g As Graphics, rect As Rectangle, buttonState As ButtonState, style As GridStyleInfo)
+ Dim drawPressed As Boolean = (buttonState And ButtonState.Pushed) <> 0
+ Dim hilight As Color = SystemColors.ControlLightLight
+ Dim shadow As Color = SystemColors.ControlDarkDark
+ If Not drawPressed Then
+ GridPaint.Draw3dFrame(g, rect.Left, rect.Top, rect.Right - 1, rect.Bottom - 1, 1, hilight, shadow)
+ Else
+ Dim br = New SolidBrush(shadow)
+ g.FillRectangle(br, Rectangle.FromLTRB(rect.Left, rect.Bottom - 1, rect.Right - 1, rect.Bottom))
+ g.FillRectangle(br, Rectangle.FromLTRB(rect.Right - 1, rect.Top, rect.Right, rect.Bottom))
+ br.Dispose()
+ End If
+ End Sub 'OnDrawCellButtonBackground
+
+
+ public override bool ValidateString(string text)
+ {
+ TraceUtil.TraceCurrentMethodInfoIf(Switches.CellRenderer.TraceVerbose, text);
+ if (text.IndexOf("-") != -1)
+ return false;
+ return true;
+ }
+
+
+ form.Text = "Password Cells";
+ gridControl1.BeginUpdate();
+ gridControl1.TableStyle.FloatCell = true;
+ gridControl1.FloatCellsMode = GridFloatCellsMode.OnDemandCalculation;
+ gridControl1.TableStyle.BackColor = Color.FromArgb(204, 212, 230);
+ gridControl1.TableStyle.CellType = "OriginalTextBox";
+ GridStyleInfo style;
+ for (int row = 2; row != 10; row++)
+ {
+ style = gridControl1[row, 2];
+ style.PasswordChar = '*';
+ style.Text = new string((char) (65 + row), row);
+ style = gridControl1[row, 3];
+ style.CharacterCasing = CharacterCasing.Lower;
+ style.Text = new string((char) (65 + row), row);
+ style = gridControl1[row, 4];
+ style.CharacterCasing = CharacterCasing.Upper;
+ style.Text = new string((char) (65 + row), row);
+ }
+ gridControl1.EndUpdate(true);
+
+
+ form.Text = "Password Cells"
+ gridControl1.BeginUpdate()
+ gridControl1.TableStyle.FloatCell = True
+ gridControl1.FloatCellsMode = GridFloatCellsMode.OnDemandCalculation
+ gridControl1.TableStyle.BackColor = Color.FromArgb(204, 212, 230)
+ gridControl1.TableStyle.CellType = "OriginalTextBox"
+ Dim style As GridStyleInfo
+ Dim row As Integer
+ For row = 2 To 10
+ style = gridControl1(row, 2)
+ style.PasswordChar = "*"c
+ style.Text = New String(ChrW(65 + row), row)
+ style = gridControl1(row, 3)
+ style.CharacterCasing = CharacterCasing.Lower
+ style.Text = New String(ChrW(65 + row), row)
+ style = gridControl1(row, 4)
+ style.CharacterCasing = CharacterCasing.Upper
+ style.Text = New String(ChrW(65 + row), row)
+ Next row
+ gridControl1.EndUpdate(True)
+
+
+ //Enable the Office2007ScrollBars.
+ this.gridControl1.Office2007ScrollBars = true;
+ //Set the color for office2007ScrollBars.
+ this.gridControl1.Office2007ScrollBarsColorScheme = Office2007ColorScheme.Black;
+
+
+ 'Enable the Office2007ScrollBars.
+ Me.gridControl1.Office2007ScrollBars = True
+ 'Set the color for office2007ScrollBars.
+ Me.gridControl1.Office2007ScrollBarsColorScheme = Office2007ColorScheme.Black
+
+
+ //Creates the Graphics for the control.
+ Graphics graphics = this.gridControl1.CreateGridGraphics();
+
+
+ 'Creates the Graphics for the control.
+ Dim graphics As Graphics = Me.gridControl1.CreateGridGraphics()
+
+
+ void gridControl1_CellClick(object sender, GridCellClickEventArgs e)
+ {
+ GridStyleInfo style;
+ style = this.gridControl1.GetViewStyleInfo(e.RowIndex,e.ColIndex);
+ }
+
+
+ Private Sub gridControl1_CellClick(ByVal sender As Object, ByVal e As GridCellClickEventArgs)
+ Dim style As GridStyleInfo
+ style = Me.gridControl1.GetViewStyleInfo(e.RowIndex,e.ColIndex)
+ End Sub
+
+
+ bool drawDirectToDC = true;
+ Graphics g = null;
+ if (drawDirectToDC)
+ g = m_syncGrid.CreateGridGraphics();
+ // Clear our volatile cache
+ m_syncGrid.ResetVolatileData();
+ // Handle case when values is change for current cell.
+ if (g1 == m_syncGrid.CurrentCell.RangeInfo)
+ {
+ m_syncGrid.CurrentCell.Model.ResetActiveText(row, col);
+ continue;
+ }
+ // Draw direct to dc
+ if (drawDirectToDC)
+ {
+ Rectangle bounds = m_syncGrid.RangeInfoToRectangle(g1);
+ if (!bounds.IsEmpty)
+ {
+ // Instead of
+ if (false)
+ {
+ // Draw each cell individually to graphics context
+ GridStyleInfo style = this.m_syncGrid.Model[row, col];
+ GridCellRendererBase renderer = this.m_syncGrid.CellRenderers[style.CellType];
+ // Get client rectangle
+ bounds = style.CellModel.SubtractBorders(bounds, style, this.m_syncGrid.IsRightToLeft());
+ // Draw cell Background
+ Syncfusion.Drawing.BrushPaint.FillRectangle(g, bounds, style.Interior);
+ // Draw cell text
+ renderer.Draw(g, bounds, row, col, style);
+ }
+ else
+ {
+ // DrawClippedGrid method lets you simply draw the cells at the specified bounds directly to the graphics context.
+ // less code than drawing each cell individually ....
+ m_syncGrid.DrawClippedGrid(g, bounds);
+ }
+ }
+ else
+ {
+ // Use more conventional Invalidate / Update mechanism.
+ m_syncGrid.RefreshRange(GridRangeInfo.Cell(row, col);
+ }
+ if (g != null)
+ g.Dispose();
+
+
+ public Form1()
+ {
+ InitializeComponent();
+ this.gridDataBoundGrid2.CurrentCellInitializeControlText += new GridCurrentCellInitializeControlTextEventHandler(gridDataBoundGrid2_CurrentCellInitializeControlText);
+ this.sqlDataAdapter1.Fill(this.dataSet11);
+ }
+ void gridDataBoundGrid2_CurrentCellInitializeControlText(object sender, GridCurrentCellInitializeControlTextEventArgs e)
+ {
+ if (e.CellValue != null)
+ {
+ e.ControlText = e.CellValue.ToString();
+ }
+ }
+
+
+ public Form1()
+ {
+ InitializeComponent();
+ this.gridDataBoundGrid2.CurrentCellErrorMessage += new GridCurrentCellErrorMessageEventHandler(gridDataBoundGrid2_CurrentCellErrorMessage);
+ this.sqlDataAdapter1.Fill(this.dataSet11);
+ }
+ void gridDataBoundGrid2_CurrentCellErrorMessage(object sender, GridCurrentCellErrorMessageEventArgs e)
+ {
+ MessageBox.Show(e.Owner, e.Text);
+ e.Cancel = true;
+ }
+
+
+ public override void OnCurrentCellValidateString(GridCurrentCellValidateStringEventArgs e)
+ {
+ TraceUtil.TraceCurrentMethodInfoIf(Switches.CellRenderer.TraceVerbose, e);
+ if (e.Text.IndexOf("-") != -1)
+ e.Cancel = true;
+ base.OnCurrentCellValidateString(e);
+ }
+
+
+ /// Current cell will be moving from one position to another.
+ protected override void OnCurrentCellMoving(GridCurrentCellMovingEventArgs e)
+ {
+ e.Options |= GridSetCurrentCellOptions.BeginEndUpdate;
+ // Instead of GridSetCurrentCellOptions.BeginEndUpdate we could also
+ // sandwich the call in a Begin/EndUpdate pair ourselves ...
+ //BeginUpdate(BeginUpdateOptions.InvalidateAndScroll);
+ }
+ /// Completes a current cell's MoveTo operation indicating success.
+ protected override void OnCurrentCellMoved(GridCurrentCellMovedEventArgs e)
+ {
+ base.OnCurrentCellMoved(e);
+ //EndUpdate();
+ }
+ /// Completes a current cell's MoveTo operation indicating failure.
+ protected override void OnCurrentCellMoveFailed(GridCurrentCellMoveFailedEventArgs e)
+ {
+ base.OnCurrentCellMoveFailed(e);
+ //EndUpdate();
+ }
+ /// Highlight the current row.
+ protected override void OnPrepareViewStyleInfo(GridPrepareViewStyleInfoEventArgs e)
+ {
+ if (e.RowIndex > this.Model.Rows.HeaderCount && e.ColIndex > this.Model.Cols.HeaderCount
+ && CurrentCell.HasCurrentCellAt(e.RowIndex))
+ {
+ e.Style.Interior = new BrushInfo(SystemColors.Highlight);
+ e.Style.TextColor = SystemColors.HighlightText;
+ e.Style.Font.Bold = true;
+ }
+ base.OnPrepareViewStyleInfo(e);
+ }
+ /// Refresh the whole row for the old position of the current cell when it is moved to
+ /// a new row or when current cell is deactivated stand-alone.
+ protected override void OnCurrentCellDeactivated(GridCurrentCellDeactivatedEventArgs e)
+ {
+ // Check if Deactivate is called stand-alone or called from MoveTo and row is moving.
+ if (!CurrentCell.IsInMoveTo || CurrentCell.MoveToRowIndex != CurrentCell.MoveFromRowIndex)
+ {
+ RefreshRange(GridRangeInfo.Row(e.RowIndex), GridRangeOptions.MergeAllSpannedCells);
+ }
+ base.OnCurrentCellDeactivated(e);
+ }
+ /// Refresh the whole row for the new current cell position when the current cell is moved
+ /// to a new row or when current cell is activated stand-alone (and there was no activated current cell).
+ protected override void OnCurrentCellActivated(EventArgs e)
+ {
+ // Check if Activate is called stand-alone or called from MoveTo and row is moving
+ base.OnCurrentCellActivated(e);
+ if (!CurrentCell.IsInMoveTo || CurrentCell.MoveToRowIndex != CurrentCell.MoveFromRowIndex
+ || !CurrentCell.MoveFromActiveState)
+ {
+ RefreshRange(GridRangeInfo.Row(CurrentCell.RowIndex), GridRangeOptions.MergeAllSpannedCells);
+ }
+ }
+
+
+ GridStyleInfo style = Model[rowIndex, colIndex];
+ GridCellRendererBase renderer = CellRenderers[style.CellType];
+
+
+ gridTableControl.UpdateWithCustomPaint(bounds, new PaintEventHandler(TableControl_CustomPaint));
+ void TableControl_CustomPaint(object sender, PaintEventArgs e)
+ {
+ Rectangle clipBounds = Rectangle.Truncate(e.Graphics.ClipBounds);
+ gridTableControl.DrawClippedGrid(e.Graphics, clipBounds, false);
+ }
+
+
+ GridControlBase grid;
+ int min = grid.GetMinimumTopRowIndex();
+ int max = grid.GetMaximumTopRowIndex();
+ for (int v = min; v <= max; v++)
+ {
+ grid.TopRowIndex = v;
+ }
+
+
+ Dim grid As GridControlBase
+ int min = grid.GetMinimumTopRowIndex();
+ int max = grid.GetMaximumTopRowIndex();
+ for (int v = min; v <= max; v++)
+ {
+ grid.TopRowIndex = v;
+ }
+
+
+ GridControlBase grid;
+ int min = grid.GetMinimumTopRowIndex();
+ int max = grid.GetMaximumTopRowIndex();
+ for (int v = min; v <= max; v++)
+ {
+ grid.TopRowIndex = v;
+ }
+
+
+ Dim grid As GridControlBase
+ int min = grid.GetMinimumTopRowIndex();
+ int max = grid.GetMaximumTopRowIndex();
+ for (int v = min; v <= max; v++)
+ {
+ grid.TopRowIndex = v;
+ }
+
+
+ GridControlBase grid;
+ int min = grid.GetMinimumLeftColIndex();
+ int max = grid.GetMaximumLeftColIndex();
+ for (int v = min; v <= max; v++)
+ {
+ grid.LeftColIndex = v;
+ }
+
+
+ Dim grid As GridControlBase
+ int min = grid.GetMinimumLeftColIndex();
+ int max = grid.GetMaximumLeftColIndex();
+ for (int v = min; v <= max; v++)
+ {
+ grid.LeftColIndex = v;
+ }
+
+
+ GridControlBase grid;
+ int min = grid.GetMinimumLeftColIndex();
+ int max = grid.GetMaximumLeftColIndex();
+ for (int v = min; v <= max; v++)
+ {
+ grid.LeftColIndex = v;
+ }
+
+
+ Dim grid As GridControlBase
+ int min = grid.GetMinimumLeftColIndex();
+ int max = grid.GetMaximumLeftColIndex();
+ for (int v = min; v <= max; v++)
+ {
+ grid.LeftColIndex = v;
+ }
+
+
+ public static void Draw3dFrame(Graphics g, int x0, int y0, int x1, int y1, int w, Color rgbTopLeft, Color rgbBottomRight)
+ {
+ Rectangle rc;
+ for (int i = 0; i != w; i++)
+ {
+ // Top
+ Brush brTL = new SolidBrush(rgbTopLeft);
+ rc = Rectangle.FromLTRB(x0, y0, x1, y0+1);
+ g.FillRectangle(brTL, rc);
+ // Left
+ rc = Rectangle.FromLTRB(x0, y0, x0+1, y1);
+ g.FillRectangle(brTL, rc);
+ brTL.Dispose();
+ Brush brBR = new SolidBrush(rgbBottomRight);
+ // Bottom
+ rc = Rectangle.FromLTRB(x0, y1, x1+1, y1+1);
+ g.FillRectangle(brBR, rc);
+ // Right
+ rc = Rectangle.FromLTRB(x1, y0, x1+1, y1);
+ g.FillRectangle(brBR, rc);
+ brBR.Dispose();
+ if (i != w-1)
+ {
+ x0++;
+ y0++;
+ x1--;
+ y1--;
+ }
+ }
+ }
+ protected override void OnDrawCellButtonBackground(GridDrawCellButtonBackgroundEventArgs e)
+ {
+ bool drawPressed = (e.ButtonState & ButtonState.Pushed) != 0;
+ Rectangle rect = e.Bounds;
+ Graphics g = e.Graphics;
+ Color hilight = SystemColors.ControlLightLight;
+ Color shadow = SystemColors.ControlDarkDark;
+ if (!drawPressed)
+ {
+ Draw3dFrame(e.Graphics, rect.Left, rect.Top, rect.Right-1, rect.Bottom-1, 1,
+ hilight, shadow);
+ }
+ else
+ {
+ Brush br = new SolidBrush(shadow);
+ g.FillRectangle(br, Rectangle.FromLTRB(rect.Left, rect.Bottom-1, rect.Right-1, rect.Bottom));
+ g.FillRectangle(br, Rectangle.FromLTRB(rect.Right-1, rect.Top, rect.Right, rect.Bottom));
+ br.Dispose();
+ }
+ e.Cancel = true;
+ }
+
+
+ /// Current cell will be moving from one position to another.
+ protected override void OnCurrentCellMoving(GridCurrentCellMovingEventArgs e)
+ {
+ e.Options |= GridSetCurrentCellOptions.BeginEndUpdate;
+ }
+ /// Highlight the current row.
+ protected override void OnPrepareViewStyleInfo(GridPrepareViewStyleInfoEventArgs e)
+ {
+ if (e.RowIndex > this.Model.Rows.HeaderCount && e.ColIndex > this.Model.Cols.HeaderCount
+ && CurrentCell.HasCurrentCellAt(e.RowIndex))
+ {
+ e.Style.Interior = new BrushInfo(SystemColors.Highlight);
+ e.Style.TextColor = SystemColors.HighlightText;
+ e.Style.Font.Bold = true;
+ }
+ base.OnPrepareViewStyleInfo(e);
+ }
+ /// Refresh the whole row for the old position of the current cell when it is moved to
+ /// a new row or when current cell is deactivated stand-alone.
+ protected override void OnCurrentCellDeactivated(GridCurrentCellDeactivatedEventArgs e)
+ {
+ // Check if Deactivate is called stand-alone or called from MoveTo and row is moving
+ if (!CurrentCell.IsInMoveTo || CurrentCell.MoveToRowIndex != CurrentCell.MoveFromRowIndex)
+ {
+ RefreshRange(GridRangeInfo.Row(e.RowIndex), GridRangeOptions.MergeAllSpannedCells);
+ }
+ base.OnCurrentCellDeactivated(e);
+ }
+ /// Refresh the whole row for the new current cell position when the current cell is moved
+ /// to a new row or when current cell is activated stand-alone (and there was no activated current cell).
+ protected override void OnCurrentCellActivated(EventArgs e)
+ {
+ // Check if Activate is called stand-alone or called from MoveTo and row is moving
+ base.OnCurrentCellActivated(e);
+ if (!CurrentCell.IsInMoveTo || CurrentCell.MoveToRowIndex != CurrentCell.MoveFromRowIndex
+ || !CurrentCell.MoveFromActiveState)
+ {
+ RefreshRange(GridRangeInfo.Row(CurrentCell.RowIndex), GridRangeOptions.MergeAllSpannedCells);
+ }
+ }
+
+
+ /// Current cell will be moving from one position to another.
+ protected override void OnCurrentCellMoving(GridCurrentCellMovingEventArgs e)
+ {
+ e.Options |= GridSetCurrentCellOptions.BeginEndUpdate;
+ // Instead of GridSetCurrentCellOptions.BeginEndUpdate we could also
+ // sandwich the call in a Begin/EndUpdate pair ourselves ...
+ //BeginUpdate(BeginUpdateOptions.InvalidateAndScroll);
+ }
+ /// Completes a current cell's MoveTo operation indicating success.
+ protected override void OnCurrentCellMoved(GridCurrentCellMovedEventArgs e)
+ {
+ base.OnCurrentCellMoved(e);
+ //EndUpdate();
+ }
+ /// Completes a current cell's MoveTo operation indicating failure.
+ protected override void OnCurrentCellMoveFailed(GridCurrentCellMoveFailedEventArgs e)
+ {
+ base.OnCurrentCellMoveFailed(e);
+ //EndUpdate();
+ }
+ /// Highlight the current row.
+ protected override void OnPrepareViewStyleInfo(GridPrepareViewStyleInfoEventArgs e)
+ {
+ if (e.RowIndex > this.Model.Rows.HeaderCount && e.ColIndex > this.Model.Cols.HeaderCount
+ && CurrentCell.HasCurrentCellAt(e.RowIndex))
+ {
+ e.Style.Interior = new BrushInfo(SystemColors.Highlight);
+ e.Style.TextColor = SystemColors.HighlightText;
+ e.Style.Font.Bold = true;
+ }
+ base.OnPrepareViewStyleInfo(e);
+ }
+ /// Refresh the whole row for the old position of the current cell when it is moved to
+ /// a new row or when current cell is deactivated stand-alone.
+ protected override void OnCurrentCellDeactivated(GridCurrentCellDeactivatedEventArgs e)
+ {
+ // Check if Deactivate is called stand-alone or called from MoveTo and row is moving.
+ if (!CurrentCell.IsInMoveTo || CurrentCell.MoveToRowIndex != CurrentCell.MoveFromRowIndex)
+ {
+ RefreshRange(GridRangeInfo.Row(e.RowIndex), GridRangeOptions.MergeAllSpannedCells);
+ }
+ base.OnCurrentCellDeactivated(e);
+ }
+ /// Refresh the whole row for the new current cell position when the current cell is moved
+ /// to a new row or when current cell is activated stand-alone (and there was no activate current cell).
+ protected override void OnCurrentCellActivated(EventArgs e)
+ {
+ // Check if Activate is called stand-alone or called from MoveTo and row is moving
+ base.OnCurrentCellActivated(e);
+ if (!CurrentCell.IsInMoveTo || CurrentCell.MoveToRowIndex != CurrentCell.MoveFromRowIndex
+ || !CurrentCell.MoveFromActiveState)
+ {
+ RefreshRange(GridRangeInfo.Row(CurrentCell.RowIndex), GridRangeOptions.MergeAllSpannedCells);
+ }
+ }
+
+
+ //Adjust the row and column index if it is covered cell.
+ int row = this.gridControl1.CurrentCell.RowIndex;
+ int col = this.gridControl1.CurrentCell.ColIndex;
+ this.gridControl1.CurrentCell.AdjustRowColIfCoveredCell(ref row, ref col);
+
+
+ 'Adjust the row and column if it is covered cell.
+ Dim row As Integer = Me.gridControl1.CurrentCell.RowIndex
+ Dim col As Integer = Me.gridControl1.CurrentCell.ColIndex
+ Me.gridControl1.CurrentCell.AdjustRowColIfCoveredCell(row, col)
+
+
+ this.gridControl1.ViewLayout.Lock();
+ GridRangeInfo cell = GridRangeInfo.Cell(row, col);
+ Rectangle bounds = gridControl1.RangeInfoToRectangle(cell);
+ this.gridControl1.Invalidate(bounds);
+ this.gridControl1.Update();
+ this.gridControl1.ViewLayout.Unlock();
+
+
+ GridRangeInfo range;
+ int topRow,leftCol,bottomRow,rightCol;
+ //Get the range of cell.
+ this.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, out range);
+ //Get the bounds of the cell.
+ Rectangle rectangle = this.gridControl1.ViewLayout.RangeInfoToRectangle(range);
+ this.gridControl1.ViewLayout.RectangleToClientRowCol(rectangle,out topRow,out leftCol,out bottomRow,out rightCol,GridCellSizeKind.ActualSize);
+
+
+ Dim range As GridRangeInfo
+ Dim topRow, leftCol, bottomRow, rightCol As Integer
+ 'Get the range of cell.
+ Me.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, range)
+ 'Get the bounds of the cell.
+ Dim rectangle As Rectangle = Me.gridControl1.ViewLayout.RangeInfoToRectangle(range)
+ Me.gridControl1.ViewLayout.RectangleToClientRowCol(rectangle,topRow,leftCol,bottomRow,rightCol,GridCellSizeKind.ActualSize)
+
+
+ GridRangeInfo range;
+ int topRow,leftCol,bottomRow,rightCol;
+ //Get the range of cell.
+ this.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, out range);
+ //Get the bounds of the cell.
+ Rectangle rectangle = this.gridControl1.ViewLayout.RangeInfoToRectangle(range);
+ this.gridControl1.ViewLayout.RectangleToClientRowCol(rectangle,out topRow,out leftCol,out bottomRow,out rightCol,GridCellSizeKind.ActualSize);
+
+
+ Dim range As GridRangeInfo
+ Dim topRow, leftCol, bottomRow, rightCol As Integer
+ 'Get the range of cell.
+ Me.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, range)
+ 'Get the bounds of the cell.
+ Dim rectangle As Rectangle = Me.gridControl1.ViewLayout.RangeInfoToRectangle(range)
+ Me.gridControl1.ViewLayout.RectangleToClientRowCol(rectangle,topRow,leftCol,bottomRow,rightCol,GridCellSizeKind.ActualSize)
+
+
+ GridControl gridControl1;
+ int visibleClientCol = this.gridControl1.ViewLayout.ColIndexToVisibleClient(5);
+ Console.WriteLine("Visible client column index:" + visibleClientCol);
+
+
+ Dim gridControl1 As GridControl
+ Dim visibleClientCol As Integer = Me.gridControl1.ViewLayout.ColIndexToVisibleClient(5)
+
+
+
+ Point point = this.gridControl1.ViewLayout.RowColToPoint(e.RowIndex, e.ColIndex,GridCellSizeKind.ActualSize);
+ Console.Write("Location:" + point);
+
+
+ Dim point As Point = Me.gridControl1.ViewLayout.RowColToPoint(e.RowIndex, e.ColIndex,GridCellSizeKind.ActualSize)
+
+
+
+ Point point = this.gridControl1.ViewLayout.RowColToPoint(e.RowIndex, e.ColIndex);
+ Console.Write("Location:" + point);
+
+
+ Dim point As Point = Me.gridControl1.ViewLayout.RowColToPoint(e.RowIndex, e.ColIndex)
+
+
+
+ GridControl gridControl1;
+ Point point = this.gridControl1.ViewLayout.ClientRowColToPoint(5, 7,GridCellSizeKind.VisibleSize);
+ Console.WriteLine("Point:" + point);
+
+
+ Dim gridControl1 As GridControl
+ Dim point As Point = Me.gridControl1.ViewLayout.ClientRowColToPoint(5, 7,GridCellSizeKind.VisibleSize)
+
+
+
+ GridControl gridControl1;
+ Point point = this.gridControl1.ViewLayout.ClientRowColToPoint(5, 7);
+ Console.WriteLine("Point:" + point);
+
+
+ Dim gridControl1 As GridControl
+ Dim point As Point = Me.gridControl1.ViewLayout.ClientRowColToPoint(5, 7)
+
+
+
+ //set ignoreOutsideClientRectangle to True, if the grid should only return points within the grid area
+ Point point = this.gridControl1.ViewLayout.RowColToPoint(e.RowIndex, e.ColIndex,true,GridCellSizeKind.ActualSize);
+ Console.Write("Location:" + point);
+
+
+ 'set ignoreOutsideClientRectangle to True, if the grid should only return points within the grid area
+ Dim point As Point = Me.gridControl1.ViewLayout.RowColToPoint(e.RowIndex, e.ColIndex,True,GridCellSizeKind.ActualSize)
+
+
+
+ //set ignoreOutsideClientRectangle to True, if the grid should only return points within the grid area
+ Point point = this.gridControl1.ViewLayout.RowColToPoint(e.RowIndex, e.ColIndex,true);
+ Console.Write("Location:" + point);
+
+
+ 'set ignoreOutsideClientRectangle to True, if the grid should only return points within the grid area
+ Dim point As Point = Me.gridControl1.ViewLayout.RowColToPoint(e.RowIndex, e.ColIndex,True)
+
+
+
+ GridRangeInfo range;
+ //Get the range of cells.
+ this.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, out range);
+ Rectangle rectangle = this.gridControl1.ViewLayout.RangeInfoToRectangle(rangeGridCellSizeKind.ActualSize);
+
+
+ Dim range As GridRangeInfo
+ 'Get the range of cells.
+ Me.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, range)
+ Dim rectangle As Rectangle = Me.gridControl1.ViewLayout.RangeInfoToRectangle(range,GridCellSizeKind.ActualSize)
+
+
+ GridRangeInfo range;
+ //Get the range of cells.
+ this.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, out range);
+ Rectangle rectangle = this.gridControl1.ViewLayout.RangeInfoToRectangle(range);
+
+
+ Dim range As GridRangeInfo
+ 'Get the range of cells.
+ Me.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, range)
+ Dim rectangle As Rectangle = Me.gridControl1.ViewLayout.RangeInfoToRectangle(range)
+
+
+ GridControl gridControl1;
+ int colIndex = this.gridControl1.CurrentCell.ColIndex;
+ int colWidth = this.gridControl1.ViewLayout.GetClientColWidth(colIndexGridCellSizeKind.ActualSize);
+ Console.WriteLine("ColumnWidth:" + colWidth);
+
+
+ Dim gridControl1 As GridControl
+ Dim colIndex As Integer = Me.gridControl1.CurrentCell.ColIndex
+ Dim colWidth As Integer = Me.gridControl1.ViewLayout.GetClientColWidth(colIndex,GridCellSizeKind.ActualSize)
+ .
+
+
+ GridControl gridControl1;
+ int colIndex = this.gridControl1.CurrentCell.ColIndex;
+ int colWidth = this.gridControl1.ViewLayout.GetClientColWidth(colIndex);
+ Console.WriteLine("ColumnWidth:" + colWidth);
+
+
+ Dim gridControl1 As GridControl
+ Dim colIndex As Integer = Me.gridControl1.CurrentCell.ColIndex
+ Dim colWidth As Integer = Me.gridControl1.ViewLayout.GetClientColWidth(colIndex)
+
+
+
+ GridControl gridControl1;
+ int rowIndex = this.gridControl1.CurrentCell.RowIndex;
+ int rowHeight = this.gridControl1.ViewLayout.GetRowHeight(rowIndex,GridCellSizeKind.VisibleSize);
+ Console.WriteLine("RowHeight:" + rowHeight);
+
+
+ Dim gridControl1 As GridControl
+ Dim rowIndex As Integer = Me.gridControl1.CurrentCell.RowIndex
+ Dim rowHeight As Integer = Me.gridControl1.ViewLayout.GetRowHeight(rowIndex,GridCellSizeKind.VisibleSize)
+
+
+
+ GridControl gridControl1;
+ int rowIndex = this.gridControl1.CurrentCell.RowIndex;
+ int rowHeight = this.gridControl1.ViewLayout.GetRowHeight(rowIndex);
+ Console.WriteLine("RowHeight:" + rowHeight);
+
+
+ Dim gridControl1 As GridControl
+ Dim rowIndex As Integer = Me.gridControl1.CurrentCell.RowIndex
+ Dim rowHeight As Integer = Me.gridControl1.ViewLayout.GetRowHeight(rowIndex)
+
+
+
+ GridRangeInfo range;
+ //Get the range of cells.
+ this.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, out range);
+ //True if the grid should only return points within the grid area.
+ Rectangle rectangle = this.gridControl1.ViewLayout.RangeInfoToRectangle(range,true,GridCellSizeKind.ActualSize);
+
+
+ Dim range As GridRangeInfo
+ 'Get the range of cells.
+ Me.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, range)
+ 'True if the grid should only return points within the grid area.
+ Dim rectangle As Rectangle = Me.gridControl1.ViewLayout.RangeInfoToRectangle(range,True,GridCellSizeKind.ActualSize)
+
+
+ GridRangeInfo range;
+ //Get the range of cells.
+ this.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, out range);
+ //True if the grid should only return points within the grid area.
+ Rectangle rectangle = this.gridControl1.ViewLayout.RangeInfoToRectangle(range,true);
+
+
+ Dim range As GridRangeInfo
+ 'Get the range of cells.
+ Me.gridControl1.Model.GetSpannedRangeInfo(e.RowIndex, e.ColIndex, range)
+ 'True if the grid should only return points within the grid area.
+ Dim rectangle As Rectangle = Me.gridControl1.ViewLayout.RangeInfoToRectangle(range,True)
+
+
+ GridControl gridControl1;
+ int[] rowHeight = this.gridControl1.ViewLayout.GetRowHeights(4, 6, GridCellSizeKind.ActualSize);
+
+ Console.WriteLine("RowHeights:" + rowHeight[i]);
+
+
+ Dim gridControl1 As GridControl
+ Dim rowHeight() As Integer = Me.gridControl1.ViewLayout.GetRowHeights(4, 6, GridCellSizeKind.ActualSize)
+ For i As Integer = 0 To 2
+
+ Next i
+
+
+ GridControl gridControl1;
+ int[] rowHeight = this.gridControl1.ViewLayout.GetRowHeights(4, 6);
+
+ Console.WriteLine("RowHeights:" + rowHeight[i]);
+
+
+ Dim gridControl1 As GridControl
+ Dim rowHeight() As Integer = Me.gridControl1.ViewLayout.GetRowHeights(4, 6)
+ For i As Integer = 0 To 2
+
+ Next i
+
+
+ GridControl gridControl1;
+ int rowHeight = this.gridControl1.ViewLayout.GetRowRangeHeight(4, 6, GridCellSizeKind.VisibleSize);
+ Console.WriteLine("RowHeights:" + rowHeight);
+
+
+ Dim gridControl1 As GridControl
+ Dim rowHeight As Integer = Me.gridControl1.ViewLayout.GetRowRangeHeight(4, 6, GridCellSizeKind.VisibleSize)
+
+
+
+ GridControl gridControl1;
+ int rowHeight = this.gridControl1.ViewLayout.GetRowRangeHeight(4, 6);
+ Console.WriteLine("RowHeights:" + rowHeight);
+
+
+ Dim gridControl1 As GridControl
+ Dim rowHeight As Integer = Me.gridControl1.ViewLayout.GetRowRangeHeight(4, 6)
+
+
+
+ GridControl gridControl1;
+ int rangeWidth = this.gridControl1.ViewLayout.GetClientColRangeWidth(4, 6);
+ Console.WriteLine("RangeWidth:" + rangeWidth);
+
+
+ Dim gridControl1 As GridControl
+ Dim rangeWidth1 As Integer = Me.gridControl1.ViewLayout.GetClientColRangeWidth(4, 6)
+
+
+
+ GridControl gridControl1;
+ this.gridControl1.Model.CoveredRanges.Add(GridRangeInfo.Cells(4, 2, 5, 3));
+ void gridControl1_CellClick(object sender, GridCellClickEventArgs e)
+ {
+ GridRangeInfo range;
+ if (this.gridControl1.Model.CoveredRanges.Find(e.RowIndex, e.ColIndex, out range))
+ {
+ int rangeWidth = this.gridControl1.ViewLayout.GetClientColRangeWidth(range.Left, range.Right, GridCellSizeKind.ActualSize);
+ Console.WriteLine("RangeWidth:" + rangeWidth);
+ }
+ }
+
+
+ Private gridControl1 As GridControl
+ Me.gridControl1.Model.CoveredRanges.Add(GridRangeInfo.Cells(4, 2, 5, 3))
+ void gridControl1_CellClick(Object sender, GridCellClickEventArgs e)
+ Dim range As GridRangeInfo
+ If Me.gridControl1.Model.CoveredRanges.Find(e.RowIndex, e.ColIndex, range) Then
+ Dim rangeWidth As Integer = Me.gridControl1.ViewLayout.GetClientColRangeWidth(range.Left, range.Right, GridCellSizeKind.ActualSize)
+
+ End If
+
+
+ GridCellModelBase cellModel = grid.Model.CellModels[key];
+ GridCellRendererBase renderer = cellModel.CreateRenderer(grid);
+
+
+ //Getting the enumerator.
+ GridCellInfoCollection.GridCellInfoEnumerator cells = this.gridControl1.GridCells.GetEnumerator();
+
+
+ 'Getting the enumerator.
+ Dim cells As GridCellInfoCollection.GridCellInfoEnumerator= Me.gridControl1.GridCells.GetEnumerator()
+
+
+ this.gridControl1.Model.Data.SortByColumn(2);
+
+
+ Me.gridControl1.Model.Data.SortByColumn(2)
+
+
+ this.gridControl1.Model.Data.SortByColumn(2,ListSortDirection.Descending);
+
+
+ Me.gridControl1.Model.Data.SortByColumn(2,ListSortDirection.Descending)
+
+ This is a memory efficient way to represent a table where values can remain empty. Only rows
+ that actually contain data will allocate a
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 was empty, the row will be allocated before the value is stored.
+GridRowCollection provides methods that let you insert, remove, or rearrange columns or rows + in the table.
+
+ Syncfusion.Windows.Forms.DelayedStatusDialog handler = new Syncfusion.Windows.Forms.DelayedStatusDialog();
+ handler.Delay = 1000;
+ handler.ShowDialogPercentRule = 25; //default
+ handler.ShowMousePercentRule = 75; //default values
+ this.gridControl1.Model.OperationFeedbackListener = handler;
+
+
+ void InitializeComponent()
+ {
+ // initialize code
+ // ...
+ this.gridControl1.SaveCellText += new Syncfusion.Windows.Forms.Grid.GridCellTextEventHandler(this.gridControl1_SaveCellText);
+ this.gridControl1.QueryCellFormattedText += new Syncfusion.Windows.Forms.Grid.GridCellTextEventHandler(this.gridControl1_QueryCellFormattedText);
+ this.gridControl1.SaveCellFormattedText += new Syncfusion.Windows.Forms.Grid.GridCellTextEventHandler(this.gridControl1_SaveCellFormattedText);
+ this.gridControl1.QueryCellText += new Syncfusion.Windows.Forms.Grid.GridCellTextEventHandler(this.gridControl1_QueryCellText);
+ }
+
+ private void gridControl1_QueryCellFormattedText(object sender, Syncfusion.Windows.Forms.Grid.GridCellTextEventArgs e)
+ {
+
+ }
+
+ private void gridControl1_QueryCellText(object sender, Syncfusion.Windows.Forms.Grid.GridCellTextEventArgs e)
+ {
+
+ }
+
+ private void gridControl1_SaveCellText(object sender, Syncfusion.Windows.Forms.Grid.GridCellTextEventArgs e)
+ {
+ ParseText(e);
+ }
+
+ private void gridControl1_SaveCellFormattedText(object sender, GridCellTextEventArgs e)
+ {
+ ParseText(e);
+ }
+
+ void ParseText(GridCellTextEventArgs e)
+ {
+ // By default, the grid will display a warning message box informing the user
+ // the entered value is not valid and the user will have to change the value.
+ //
+ // In this event handler, we change the grid default's behavior such that
+ // when the user enters a value that does not fit the cell's CellValueType,
+ // the input text is accepted and no warning message is shown.
+ if (e.Handled)
+ return;
+
+ System.Globalization.CultureInfo ci = e.Style.CultureInfo;
+ System.Globalization.NumberFormatInfo nfi = ci != null ? ci.NumberFormat : null;
+ try
+ {
+ e.Style.CellValue = GridCellValueConvert.Parse(e.Text, e.Style.CellValueType, nfi, e.Style.Format);
+ }
+ catch (Exception ex)
+ {
+ if (ex is FormatException || ex.InnerException is FormatException)
+ {
+ e.Style.CellValue = e.Text;
+ // possibly could also change CellValueType here
+ e.Style.CellValueType = typeof(string);
+ // - or -
+ // you could also further analyze the input text and assign a type
+ // that fits the input text, e.g.
+ // e.Style.CellValueType = typeof(datetime);
+ // - or -
+ // e.Style.CellValueType = typeof(decimal);
+ // etc.
+ }
+ else
+ throw;
+ }
+ e.Handled = true;
+ }
+
+
+ Private Sub InitializeComponent()
+ ' Initalize code
+ ' ...
+ AddHandler Me.gridControl1.SaveCellText, AddressOf Me.gridControl1_SaveCellText
+ AddHandler Me.gridControl1.QueryCellFormattedText, AddressOf Me.gridControl1_QueryCellFormattedText
+ AddHandler Me.gridControl1.SaveCellFormattedText, AddressOf Me.gridControl1_SaveCellFormattedText
+ AddHandler Me.gridControl1.QueryCellText, AddressOf Me.gridControl1_QueryCellText
+ End Sub 'InitializeComponent
+
+ Private Sub gridControl1_QueryCellFormattedText(sender As Object, e As Syncfusion.Windows.Forms.Grid.GridCellTextEventArgs)
+ End Sub 'gridControl1_QueryCellFormattedText
+
+ Private Sub gridControl1_QueryCellText(sender As Object, e As Syncfusion.Windows.Forms.Grid.GridCellTextEventArgs)
+ End Sub 'gridControl1_QueryCellText
+
+ Private Sub gridControl1_SaveCellText(sender As Object, e As Syncfusion.Windows.Forms.Grid.GridCellTextEventArgs)
+ ParseText(e)
+ End Sub 'gridControl1_SaveCellText
+
+ Private Sub gridControl1_SaveCellFormattedText(sender As Object, e As GridCellTextEventArgs)
+ ParseText(e)
+ End Sub 'gridControl1_SaveCellFormattedText
+
+ Sub ParseText(e As GridCellTextEventArgs)
+ ' By default, the grid will display a warning message box informing the user
+ ' the entered value is not valid and the user will have to change the value.
+ '
+ ' In this event handler we change the grid default's behavior such that
+ ' when the user enters a value that does not fit the cell's CellValueType,
+ ' the input text is accepted and no warning message is shown.
+ If e.Handled Then
+ Return
+ End If
+ Dim ci As System.Globalization.CultureInfo = e.Style.CultureInfo
+ Dim nfi As System.Globalization.NumberFormatInfo = Nothing
+ If (Not (ci Is Nothing)) Then nfi = ci.NumberFormat
+ Try
+ e.Style.CellValue = GridCellValueConvert.Parse(e.Text, e.Style.CellValueType, nfi, e.Style.Format)
+ Catch ex As Exception
+ If TypeOf ex Is FormatException OrElse TypeOf ex.InnerException Is FormatException Then
+ e.Style.CellValue = e.Text
+ ' possibly could also change CellValueType here
+ ' e.Style.CellValueType = typeof(string);
+ ' - or -
+ ' you could also further analyze the input text and assign a type
+ ' that fits the input text, e.g.
+ ' e.Style.CellValueType = typeof(datetime);
+ ' - or -
+ ' e.Style.CellValueType = typeof(decimal);
+ ' etc.
+ Else
+ Throw
+ End If
+ End Try
+ e.Handled = True
+ End Sub 'ParseText
+
+
+ e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
+
+
+ IGraphicsProvider graphicsProvider = this.GetGraphicsProvider(); // It is important to hold onto this object as long ad Graphics context is needed!
+ Graphics g = graphicsProvider.Graphics; // Do not dispose this object! It is a cached Display Device context.
+ // If nested method calls do call GetGraphicsProvider and get a graphics context the
+ // same cached graphics context can be returned.
+
+
+ Dim graphicsProvider as IGraphicsProvider = this.GetGraphicsProvider() ' It is important to hold onto this object as long ad Graphics context is needed!
+ Dim g as Graphics = graphicsProvider.Graphics ' Do not dispose this object! It is a cached Display Device context.
+ ' If nested method calls do call GetGraphicsProvider and get a graphics context the
+ ' same cached graphics context can be returned.
+
+
+ // Cell value for all the grid cells will be changed as "Sample"
+ this.gridControl1.Model.BaseStylesMap["Standard"].StyleInfo.CellValue = "Sample";
+ // Backcolor for all the header cells (Row and Column) will be changed as "Red"
+ this.gridControl1.Model.BaseStylesMap["Header"].StyleInfo.BackColor = Color.Red;
+
+
+ ' Cell value for all the grid cells will be changed as "Sample"
+ Me.gridControl1.Model.BaseStylesMap("Standard").StyleInfo.CellValue = "Sample"
+ ' Backcolor for all the header cells (Row and Column) will be changed as "Red"
+ Me.gridControl1.Model.BaseStylesMap("Header").StyleInfo.BackColor = Color.Red
+
+
+ // Hiding the first row.
+ this.gridControl1.Model.HideRows[1] = true;
+ // Removing the first row from hidden.
+ this.gridControl1.Model.HideRows [3] = false;
+
+
+ ' Hiding the first row.
+ Me.gridControl1.Model.HideRows(1) = True
+ ' Removing the first row from hidden.
+ Me.gridControl1.Model.HideRows (3) = False
+
+
+ // Hiding the first column.
+ this.gridControl1.Model.HideCols[1] = true;
+ // Removing the second column from hidden.
+ this.gridControl1.Model.HideCols[4] = false;
+
+
+ ' Hiding the first column.
+ Me.gridControl1.Model.HideCols(1) = True
+ ' Removing the second column from hidden.
+ Me.gridControl1.Model.HideCols(4) = False
+
+
+ // Undo the actions in the grid.
+ this.gridControl1.Model.CommandStack.Undo();
+ //Redo the actions in the grid.
+ this.gridControl1.Model.CommandStack.Redo();
+ // Getting the current command mode of the grid.
+ GridCommandMode commandMode = this.gridControl1.Model.CommandStack.Mode;
+
+
+ ' Undo the actions in the grid.
+ Me.gridControl1.Model.CommandStack.Undo()
+ 'Redo the actions in the grid.
+ Me.gridControl1.Model.CommandStack.Redo()
+ ' Getting the current command mode of the grid.
+ Dim commandMode As GridCommandMode = Me.gridControl1.Model.CommandStack.Mode
+
+
+ model[2, 2].Text = "Grid Demo";
+ model[2, 2].Font.Bold = true;
+ model[2, 2].Font.Size = 16;
+ model[2, 2].HorizontalAlignment = GridHorizontalAlignment.Center;
+ model[2, 2].VerticalAlignment = GridVerticalAlignment.Middle;
+ model[2, 2].CellType = "Static";
+ model[2, 2].Borders.All = new GridBorder(GridBorderStyle.Solid, Color.FromArgb(100, 238, 122, 3));
+ model[2, 2].Interior = new BrushInfo(GradientStyle.PathEllipse, Color.FromArgb(100, 57, 73, 122), Color.FromArgb(237, 240, 247));
+
+ If you query for specific attributes in a cell and these attributes have not been explicitly set for the cell,
+ the
+ GridStyleInfo standard = model.BaseStylesMap["Standard"].StyleInfo;
+ standard.TextColor = Color.FromArgb(0, 21, 84);
+ Color color = model[1, 1].TextColor;
+ // model[1, 1].TextColor will return Color.FromArgb(0, 21, 84));
+
+
+ // Populating DataSource
+ DataTable dataTable = new DataTable("Sample");
+ dataTable.Columns.Add("Column 1");
+ dataTable.Columns.Add("Column 2");
+ dataTable.Columns.Add("Column 3");
+ dataTable.Columns.Add("Column 4");
+ dataTable.Rows.Add("Row1", "Row2", "Row3", "Row4");
+ //Populating the values to grid
+ this.gridControl1.PopulateValues(GridRangeInfo.Cells(1, 1, dataTable.Rows.Count, dataTable.Columns.Count), dataTable);
+
+
+ ' Populating DataSource
+ Dim dataTable As New DataTable("Sample")
+ dataTable.Columns.Add("Column 1")
+ dataTable.Columns.Add("Column 2")
+ dataTable.Columns.Add("Column 3")
+ dataTable.Columns.Add("Column 4")
+ dataTable.Rows.Add("Row1", "Row2", "Row3", "Row4")
+ 'Populating the values to grid
+ Me.gridControl1.PopulateValues(GridRangeInfo.Cells(1, 1, dataTable.Rows.Count, dataTable.Columns.Count), dataTable)
+
+
+ // Populating DataSource
+ DataTable dataTable = new DataTable("Sample");
+ dataTable.Columns.Add("Column 1");
+ dataTable.Columns.Add("Column 2");
+ dataTable.Columns.Add("Column 3");
+ dataTable.Columns.Add("Column 4");
+ dataTable.Rows.Add("Row1", "Row2", "Row3", "Row4");
+ // Populating the headers
+ this.gridControl1.PopulateHeaders(GridRangeInfo.Cells(0, 1, 0, 4), dataTable);
+
+
+ ' Populating DataSource
+ Dim dataTable As New DataTable("Sample")
+ dataTable.Columns.Add("Column 1")
+ dataTable.Columns.Add("Column 2")
+ dataTable.Columns.Add("Column 3")
+ dataTable.Columns.Add("Column 4")
+ dataTable.Rows.Add("Row1", "Row2", "Row3", "Row4")
+ ' Populating the headers
+ Me.gridControl1.PopulateHeaders(GridRangeInfo.Cells(0, 1, 0, 4), dataTable)
+
+
+ // Setting whole column's styles.
+ this.gridControl1.Model.ColStyles[1].BackColor = Color.Red;
+ this.gridControl1.Model.ColStyles[1].Font.Facename = "Segoe UI";
+ this.gridControl1.Model.ColStyles[1].Font.Bold = true;
+
+
+ ' Setting whole column's styles.
+ Me.gridControl1.Model.ColStyles(1).BackColor = Color.Red
+ Me.gridControl1.Model.ColStyles(1).Font.Facename = "Segoe UI"
+ Me.gridControl1.Model.ColStyles(1).Font.Bold = True
+
+
+ // Setting whole Row’s styles.
+ this.gridControl1.Model. RowStyles[1].BackColor = Color.Red;
+ this.gridControl1.Model. RowStyles[1].Font.Facename = "Segoe UI";
+ this.gridControl1.Model. RowStyles[1].Font.Bold = true;
+
+
+ ' Setting whole Row’s styles.
+ Me.gridControl1.Model.RowStyles(1).BackColor = Color.Red
+ Me.gridControl1.Model.RowStyles(1).Font.Facename = "Segoe UI"
+ Me.gridControl1.Model.RowStyles(1).Font.Bold = True
+
+
+ this.gridControl1.Model.TableStyle.TextColor = Color.Red;
+ this.gridControl1.Model.TableStyle.Font.Facename = "Segoe UI";
+ this.gridControl1.Model.TableStyle.Font.Size = 15;
+
+
+ Me.gridControl1.Model.TableStyle.TextColor = Color.Red
+ Me.gridControl1.Model.TableStyle.Font.Facename = "Segoe UI"
+ Me.gridControl1.Model.TableStyle.Font.Size = 15
+
+
+ GridStyleInfo style = GetCombinedStyle(GridRangeInfo.Cells(2, 2, 4, 8));
+ bool isBold = style.Font.Bold;
+
+
+ GridStyleInfo boldFontStyle = new GridStyleInfo();
+ boldFontStyle.TextColor = Color.FromArgb(238, 122, 3);
+ boldFontStyle.Font = boldFont;
+ model[rowIndex, 1].Text = "Interior";
+ model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle);
+
+
+ Dim boldFontStyle As New GridStyleInfo()
+ boldFontStyle.TextColor = Color.FromArgb(238, 122, 3)
+ boldFontStyle.Font = boldFont
+ model(rowIndex, 1).Text = "Interior"
+ model.ChangeCells(GridRangeInfo.Cell(rowIndex, 1), boldFontStyle)
+
+
+ // The target range to set the text.
+ GridRangeInfo range = GridRangeInfo.Cols(1, 2);
+ //Setting the "SampleData" text to target range.
+ this.gridControl1.Model.ChangeCells(range, "SampleData");
+
+
+ ' The target range to set the text.
+ Dim range As GridRangeInfo = GridRangeInfo.Cols(1, 2)
+ 'Setting the "SampleData" text to target range.
+ Me.gridControl1.Model.ChangeCells(range, "SampleData")
+
+
+ // Defining the new cell styles.
+ GridStyleInfo newStyle = new GridStyleInfo();
+ newStyle.CellType = GridCellTypeName.ComboBox;
+ // Setting the styles of range of cells to new style.
+ this.gridControl1.Model.ChangeCells(GridRangeInfo.Rows(1, 2), newStyle);
+
+
+ ' Defining the new cell styles.
+ Dim newStyle As New GridStyleInfo()
+ newStyle.CellType = GridCellTypeName.ComboBox
+ ' Setting the styles of range of cells to new style.
+ Me.gridControl1.Model.ChangeCells(GridRangeInfo.Rows(1, 2), newStyle)
+
+
+ // Defining the new cell styles.
+ GridStyleInfo newStyle = new GridStyleInfo();
+ newStyle.CellType = GridCellTypeName.ComboBox;
+ // Setting the styles of range of cells to new style.
+ this.gridControl1.Model.ChangeCells(GridRangeInfo.Rows(1, 2), newStyle, Syncfusion.Styles.StyleModifyType.Changes);
+
+
+ ' Defining the new cell styles.
+ Dim newStyle As New GridStyleInfo()
+ newStyle.CellType = GridCellTypeName.ComboBox
+ ' Setting the styles of range of cells to new style.
+ Me.gridControl1.Model.ChangeCells(GridRangeInfo.Rows(1, 2), newStyle, Syncfusion.Styles.StyleModifyType.Changes)
+
+
+ GridStyleInfo style1 = new GridStyleInfo();
+ style2 = new GridStyleInfo();
+ style2.BackColor = Color.Red;
+ GridStyleInfo[] styles = { style1, style2 };
+ GridRangeInfo range = GridRangeInfo.Rows(6, 7);
+ this.gridControl1.Model.ChangeCells(range, styles);
+
+
+ Dim style1 As New GridStyleInfo()
+ style1.TextColor = Color.Blue
+ Dim style2 As New GridStyleInfo()
+ style2.BackColor = Color.Red
+ Dim styles() As GridStyleInfo = { style1, style2 }
+ Dim range As GridRangeInfo = GridRangeInfo.Rows(6, 7)
+ Me.gridControl1.Model.ChangeCells(range, styles)
+
+
+ // Defining the covered range.
+ GridRangeInfo coveredRange = GridRangeInfo.Cells(1, 2, 5, 5);
+ // Adding the range to be covered.
+ this.gridControl1.Model.CoveredRanges.Add(coveredRange);
+ //Finding range of covered cells.
+ GridRangeInfo range = this.gridControl1.Model.CoveredRanges.FindRange(e.RowIndex, e.ColIndex);
+ // Check whether the current cell is covered or not.
+ GridRangeInfo range;
+ if(this.gridControl1.Model.CoveredRanges.Find(e.RowIndex,e.ColIndex,out range))
+ {
+ // TODO
+ // TODO
+ }
+
+
+ ' Defining the covered range.
+ Dim coveredRange As GridRangeInfo = GridRangeInfo.Cells(1, 2, 5, 5)
+ ' Adding the range to be covered.
+ Me.gridControl1.Model.CoveredRanges.Add(coveredRange)
+ 'Finding range of covered cells.
+ Dim range As GridRangeInfo = Me.gridControl1.Model.CoveredRanges.FindRange(e.RowIndex, e.ColIndex)
+ 'Check whether the current cell is covered or not.
+ Dim range As GridRangeInfo
+ If Me.gridControl1.Model.CoveredRanges.Find(e.RowIndex,e.ColIndex,range) Then
+ ' TODO
+ ' TODO
+ End If
+
+
+ //Specify the cell model to be added in the grid model with cell type name.
+ this.gridControl1.CellModels.Add("SampleCellType", new GridHeaderCellModel(this.gridControl1.Model));
+ // Set the added cell type to the cell.
+ this.gridControl1.Model.ColStyles[1].CellType = "SampleCellType";
+
+
+ 'Specify the cell model to be added in the grid model with cell type name.
+ Me.gridControl1.Model.CellModels.Add("SampleCellType", New GridHeaderCellModel(Me.gridControl1.Model))
+ 'Set the added cell type to the cell
+ Me.gridControl1.Model.ColStyles(1).CellType = "SampleCellType"
+
+
+ if (OnDefaultSizeChanging(new GridDefaultSizeChangingEventArgs(value)))
+ {
+ bool success = false;
+ int savedValue = DefaultSize;
+ try
+ {
+ defaultSize = value;
+ success = true;
+ if (model.CommandStack.ShouldGenerateUndoInfo)
+ model.CommandStack.Push(new GridModelSetDefaultSizeCommand(this, savedValue));
+ }
+ finally
+ {
+ OnDefaultSizeChanged(new GridDefaultSizeChangedEventArgs(savedValue, success));
+ }
+ }
+
+
+ private void GridQueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
+ {
+ if(e.ColIndex > 0 && e.RowIndex > 0)
+ {
+ e.Style.CellValue = this.intArray[e.RowIndex - 1, e.ColIndex - 1];
+ e.Handled = true;
+ }
+ }
+
+
+ Private Sub GridQueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs)
+ If ((e.ColIndex > 0) AndAlso (e.RowIndex > 0)) Then
+ e.Style.CellValue = Me.intArray(e.RowIndex - 1, e.ColIndex - 1)
+ e.Handled = True
+ End If
+ End Sub
+
+
+ this.gridControl1.GridVisualStyles = GridVisualStyles.Office2007Blue;
+
+
+ Me.GridControl1.GridVisualStyles = GridVisualStyles.Office2007Blue
+
+
+ gridControl1.Selections.SelectRange(GridRangeInfo.Row(1), true);
+ gridControl1.Selections.SetSelectClickRowCol(1, 0);
+
+
+ model.ColStyles[2].Font.Bold = true;
+ model.ColStyles[2].Font.Size = 16;
+ model.ColStyles[2].HorizontalAlignment = GridHorizontalAlignment.Center;
+ model.ColStyles[2].VerticalAlignment = GridVerticalAlignment.Middle;
+ model.ColStyles[2].CellType = "Static";
+ model.ColStyles[2].Borders.All = new GridBorder(GridBorderStyle.Solid, Color.FromArgb(100, 238, 122, 3));
+ model.ColStyles[2].Interior = new BrushInfo(GradientStyle.PathEllipse, Color.FromArgb(100, 57, 73, 122), Color.FromArgb(237, 240, 247));
+
+ If you query for specific attributes in a cell and these attributes have not been explicitly set,
+ the
+ model.ColStyles[1].TextColor = Color.FromArgb(0, 21, 84);
+ Color color = model[1, 1].TextColor;
+ // model[1, 1].TextColor will return Color.FromArgb(0, 21, 84));
+
+
+ model.RowStyles[2].Font.Bold = true;
+ model.RowStyles[2].Font.Size = 16;
+ model.RowStyles[2].HorizontalAlignment = GridHorizontalAlignment.Center;
+ model.RowStyles[2].VerticalAlignment = GridVerticalAlignment.Middle;
+ model.RowStyles[2].CellType = "Static";
+ model.RowStyles[2].Borders.All = new GridBorder(GridBorderStyle.Solid, Color.FromArgb(100, 238, 122, 3));
+ model.RowStyles[2].Interior = new BrushInfo(GradientStyle.PathEllipse, Color.FromArgb(100, 57, 73, 122), Color.FromArgb(237, 240, 247));
+
+ If you query for specific attributes in a cell and these attributes have not been explicitly set for the cell,
+ the
+ model.RowStyles[1].TextColor = Color.FromArgb(0, 21, 84);
+ Color color = model[1, 1].TextColor;
+ // model[1, 1].TextColor will return Color.FromArgb(0, 21, 84));
+
+
+ GridRangeInfo cellRange = GridRangeInfo.Cell(4, 5);
+ this.gridControl1.Model.CoveredRanges.Add(cellRange);
+
+
+ Dim cellRange As GridRangeInfo = GridRangeInfo.Cell(4, 5)
+ Me.gridControl1.Model.CoveredRanges.Add(cellRange)
+
+
+ GridRangeInfo cellRange = GridRangeInfo.Cells(3, 4, 6, 7);
+ this.gridControl1.Model.CoveredRanges.Add(cellRange);
+
+
+ Dim cellRange As GridRangeInfo = GridRangeInfo.Cells(3, 4, 6, 7)
+ Me.gridControl1.Model.CoveredRanges.Add(cellRange)
+
+
+ GridRangeInfo cellRange = GridRangeInfo.Row(3);
+ this.gridControl1.Model.CoveredRanges.Add(cellRange);
+
+
+ Dim cellRange As GridRangeInfo = GridRangeInfo.Row(3)
+ Me.gridControl1.Model.CoveredRanges.Add(cellRange)
+
+
+ GridRangeInfo cellRange = GridRangeInfo.Rows(3, 4);
+ this.gridControl1.Model.CoveredRanges.Add(cellRange);
+
+
+ Dim cellRange As GridRangeInfo = GridRangeInfo.Rows(3, 4)
+ Me.gridControl1.Model.CoveredRanges.Add(cellRange)
+
+
+ GridRangeInfo cellRange = GridRangeInfo.Col(3);
+ this.gridControl1.Model.CoveredRanges.Add(cellRange);
+
+
+ Dim cellRange As GridRangeInfo = GridRangeInfo.Col(3)
+ Me.gridControl1.Model.CoveredRanges.Add(cellRange)
+
+
+ GridRangeInfo cellRange = GridRangeInfo.Cells(3, 4);
+ this.gridControl1.Model.CoveredRanges.Add(cellRange);
+
+
+ Dim cellRange As GridRangeInfo = GridRangeInfo.Cells(3, 4)
+ Me.gridControl1.Model.CoveredRanges.Add(cellRange)
+
+
+ GridRangeInfo cellRange = GridRangeInfo.Auto(4, 5);
+ this.gridControl1.Model.CoveredRanges.Add(cellRange);
+
+
+ Dim cellRange As GridRangeInfo = GridRangeInfo.Auto(4, 5)
+ Me.gridControl1.Model.CoveredRanges.Add(cellRange)
+
+
+ GridRangeInfo cellRange = GridRangeInfo.Auto(2, 5, 4, 6);
+ this.gridControl1.Model.CoveredRanges.Add(cellRange);
+
+
+ Dim cellRange As GridRangeInfo = GridRangeInfo.Auto(2, 5, 4, 6)
+ Me.gridControl1.Model.CoveredRanges.Add(cellRange)
+
+
+ GridRangeInfo firstRange = new GridRangeInfo(1, 1, 100, 100);
+ ...
+
+ GridRangeInfo firstRange = new GridRangeInfo(0, 0, 100, 100);
+
+ GridRangeInfo firstRange = new GridRangeInfo(0, 0, 100, 100);
+
+
+ GridControlBase grid = ActiveGrid;
+ if (grid != null)
+ {
+ GridBaseStylesMap.ShowGridBaseStylesMapDialog(grid.Model, "BaseStylesMap");
+ grid.Model.Refresh();
+ }
+
+
+ GridStyleInfo standard = model.BaseStylesMap["Standard"].StyleInfo;
+ GridStyleInfo header = model.BaseStylesMap["Header"].StyleInfo;
+ GridStyleInfo rowHeader = model.BaseStylesMap["Row Header"].StyleInfo;
+ GridStyleInfo colHeader = model.BaseStylesMap["Column Header"].StyleInfo;
+
+ standard.TextColor = Color.FromArgb(0, 21, 84);
+ header.Interior = new BrushInfo(GradientStyle.Vertical, Color.FromArgb(238, 234, 216), Color.FromArgb(203, 199, 184));
+ rowHeader.Interior = new BrushInfo(GradientStyle.Horizontal, Color.FromArgb(238, 234, 216), Color.FromArgb(203, 199, 184));
+ standard.Font.Facename = "Helvetica";
+ standard.Interior = new BrushInfo(Color.FromArgb(237, 240, 247));
+
+
+ GridStyleInfo customStyle = model.BaseStylesMap["Custom Style"].StyleInfo;
+ standard.Interior = new BrushInfo(Color.Green);
+ model[1, 1].BaseStyle = "Custom Style";
+
+
+ GridStyleInfo standard = model.BaseStylesMap["Standard"].StyleInfo;
+ GridStyleInfo header = model.BaseStylesMap["Header"].StyleInfo;
+ GridStyleInfo rowHeader = model.BaseStylesMap["Row Header"].StyleInfo;
+ GridStyleInfo colHeader = model.BaseStylesMap["Column Header"].StyleInfo;
+
+ standard.TextColor = Color.FromArgb(0, 21, 84);
+ header.Interior = new BrushInfo(GradientStyle.Vertical, Color.FromArgb(238, 234, 216), Color.FromArgb(203, 199, 184));
+ rowHeader.Interior = new BrushInfo(GradientStyle.Horizontal, Color.FromArgb(238, 234, 216), Color.FromArgb(203, 199, 184));
+ standard.Font.Facename = "Helvetica";
+ standard.Interior = new BrushInfo(Color.FromArgb(237, 240, 247));
+
+
+ GridStyleInfo customStyle = model.BaseStylesMap["Custom Style"].StyleInfo;
+ standard.Interior = new BrushInfo(Color.Green);
+ model[1, 1].BaseStyle = "Custom Style";
+
+
+
+ GridBorder border = new GridBorder(GridBorderStyle.Solid, Color.FromArgb(57, 73, 122));
+ model[rowIndex, colIndex].Borders.Bottom = border;
+ model[rowIndex, colIndex].Borders.Right = border;
+
+ The following code hides grid lines for specific cells:
+
+ GridBorder border = new GridBorder(GridBorderStyle.None);
+ model[rowIndex, colIndex].Borders.Bottom = border;
+ model[rowIndex, colIndex].Borders.Right = border;
+
+
+ this.gridControl1.TableStyle.Borders.All = new GridBorder(GridBorderStyle.Dotted, Color.SkyBlue);
+
+
+ Me.gridControl1.TableStyle.Borders.All = New GridBorder(GridBorderStyle.Dotted, Color.SkyBlue)
+
+
+ this.gridControl1.TableStyle.Borders.All = new GridBorder(GridBorderStyle.Dotted, Color.SkyBlue,GridBorderWeight.ExtraThick);
+
+
+ Me.gridControl1.TableStyle.Borders.All = New GridBorder(GridBorderStyle.Dotted, Color.SkyBlue)
+
+
+
+ GridBorder border = new GridBorder(GridBorderStyle.Solid, Color.FromArgb(57, 73, 122));
+ model[rowIndex, colIndex].Borders.Bottom = border;
+ model[rowIndex, colIndex].Borders.Right = border;
+
+ The following code hides grid lines for specific cells:
+
+ GridBorder border = new GridBorder(GridBorderStyle.None);
+ model[rowIndex, colIndex].Borders.Bottom = border;
+ model[rowIndex, colIndex].Borders.Right = border;
+
+
+ model[2, 2].Borders.All = new GridBorder(GridBorderStyle.Solid, Color.FromArgb(100, 238, 122, 3));
+
+
+ this.gridControl1.TableStyle.CellAppearance = GridCellAppearance.Flat;
+
+
+ Me.gridControl1.TableStyle.CellAppearance = GridCellAppearance.Flat
+
+
+ model[rowIndex, 1].Text = "Positive numbers";
+ RowStyles[rowIndex].CustomStyleProperties.Add(new GridValidateNumberStyleProperty(true, 1, float.NaN, "Please enter a number greater than 0!"));
+ model.RowStyles[rowIndex].ValidateValue.NumberRequired = true;
+ model.RowStyles[rowIndex].ValidateValue.Minimum = 0;
+ model.RowStyles[rowIndex].ValidateValue.Maximum = float.NaN;
+ model.RowStyles[rowIndex].ValidateValue.ErrorMessage = "Please enter a number greater than 0!";
+ rowIndex++;
+ model[rowIndex, 1].Text = "Validation (1-100 valid range)";
+ model.RowStyles[rowIndex].ValidateValue = new GridCellValidateValueInfo(true, 1, 100, "Please enter a number between 1 and 100!");
+
+
+ model.TableStyle.CheckBoxOptions = new GridCheckBoxCellInfo("True", "False", string.Empty, false);
+ model[rowIndex, 1].CheckBoxOptions.FlatLook = true;
+
+
+ //Scroll position based on the column index.
+ this.gridControl1.TableStyle.CheckBoxOptions = new GridCheckBoxCellInfo("Checked", "UnChecked", "Intermediate", true);
+
+
+ 'Scroll position based on the column index.
+ Me.gridControl1.TableStyle.CheckBoxOptions = New GridCheckBoxCellInfo("Checked", "UnChecked", "Intermediate", True)
+
+
+ //Default currency symbol "$".
+ this.gridControl1.TableStyle.CurrencyEdit.CurrencySymbol = "�";
+
+
+ 'Default currency symbol "$".
+ Me.gridControl1.TableStyle.CurrencyEdit.CurrencySymbol = "�"
+
+
+ this.gridControl1.TableStyle.CurrencyEdit.NegativeColor = Color.Red;
+
+
+ this.gridControl1.TableStyle.CurrencyEdit.NegativeColor = Color.Red;
+
+
+
+ model[rowIndex, colIndex].Font.Facename = "Arial";
+ model[rowIndex, colIndex].Font.Bold = true;
+
+
+ Font font = new Font("Segoe UI", 9.5f);
+ this.gridControl1.TableStyle.Font = new GridFontInfo(font);
+
+
+ Dim font As New Font("Segoe UI", 9.5f)
+ Me.gridControl1.TableStyle.Font = New GridFontInfo(font)
+
+
+ GridStyleInfo standard = model.BaseStylesMap["Standard"].StyleInfo;
+ Font dfont = Control.DefaultFont;
+ standard.Font.Unit = GraphicsUnit.World;
+ standard.Font.Facename = dfont.Name;
+ standard.Font.Size = GridFontInfo.SizeInWorldUnit(dfont);
+
+
+ Dim standard As GridStyleInfo = model.BaseStylesMap("Standard").StyleInfo
+ Dim dfont As Font = Control.DefaultFont
+ standard.Font.Unit = GraphicsUnit.World
+ standard.Font.Facename = dfont.Name
+ standard.Font.Size = GridFontInfo.SizeInWorldUnit(dfont)
+
+
+ this.gridControl1.TableStyle.HorizontalAlignment = GridHorizontalAlignment.Center;
+
+
+ Me.gridControl1.TableStyle.HorizontalAlignment = GridHorizontalAlignment.Center
+
+
+
+ GridMargins margins = new GridMargins(1, 1, 2, 2);
+ model[rowIndex, colIndex].Margins = new GridMarginsInfo(margins);
+ model[rowIndex, colIndex+1].Margins.Right = 2;
+ model[rowIndex, colIndex+1].Margins.Left = 2;
+
+
+ this.gridControl1[4, 8].CellType = GridCellTypeName.MaskEdit;
+ this.gridControl1[4, 8].MaskEdit.Mask = "###-###########";
+ //sets the character that will be used instead of mask characters when the mask position has not been filled.
+ this.gridControl1.TableStyle.MaskEdit.PaddingCharacter = 'T';
+
+
+ Me.gridControl1(4, 8).CellType = GridCellTypeName.MaskEdit
+ Me.gridControl1(4, 8).MaskEdit.Mask = "###-###########"
+ 'sets the character that will be used instead of mask characters when the mask position has not been filled.
+ Me.gridControl1.TableStyle.MaskEdit.PaddingCharacter = "T"
+
+
+ model.TableStyle.NumericUpDown = new GridNumericUpDownCellInfo(0, 25, 1, 1, true);
+ model[rowIndex, 1].Text = "NumericUpDown";
+ // Wrapping, Range 0-1000
+ model[rowIndex, 3].CellType = "NumericUpDown";
+ model[rowIndex, 3].NumericUpDown = new GridNumericUpDownCellInfo(0, 1000, 0, 1, true);
+ // Disabled
+ model[rowIndex, 4].CellType = "NumericUpDown";
+ model[rowIndex, 4].Enabled = false;
+ model[rowIndex, 4].Text = "5";
+ // No wrapping, Range 1-20
+ model[rowIndex, 5].CellType = "NumericUpDown";
+ model[rowIndex, 5].NumericUpDown = new GridNumericUpDownCellInfo(1, 20, 1, 1, false);
+ rowIndex++;
+
+
+ this.gridControl1.TableStyle.NumericUpDown = new GridNumericUpDownCellInfo(0, 1000, 5, 5, false);
+
+
+ Me.gridControl1.TableStyle.NumericUpDown = New GridNumericUpDownCellInfo(0, 1000, 5, 5, False)
+
+
+ Color c = Color.Red;
+ Color c1 = Color.Black;
+ Color[] color = new Color[] { c, c1 };
+ this.gridControl1.TableStyle.ProgressBar.MultipleColors = color;
+
+
+ Dim c As Color = Color.Red
+ Dim c1 As Color = Color.Black
+ Dim color() As Color = { c, c1 }
+ Me.gridControl1.TableStyle.ProgressBar.MultipleColors = color
+
+
+ //Align the progress bar.
+ this.gridControl1.TableStyle.ProgressBar.ProgressOrientation = Orientation.Horizontal;
+
+
+ this.gridControl.TableStyle.ProgressBar.TextOrientation = Orientation.Vertical;
+
+
+ //Set the foreground styles for progress bar.
+ this.gridControl1.TableStyle.ProgressBar.ProgressStyle = ProgressBarStyles.Tube;
+
+
+ //set the progress bar style.
+ this.gridControl1.TableStyle.ProgressBar.ProgressFallbackStyle = ProgressBarStyles.Metro;
+
+
+ //sets the style of the background when BackgroundStyle is set to System and the system can not support Themes.
+ this.gridControl1.TableStyle.ProgressBar.BackgroundFallbackStyle = ProgressBarBackgroundStyles.System;
+
+
+ 'sets the style of the background when BackgroundStyle is set to System and the system can not support Themes.
+ Me.gridControl1.TableStyle.ProgressBar.BackgroundFallbackStyle = ProgressBarBackgroundStyles.System
+
+
+ model[2, 2].Text = "Grid Demo";
+ model[2, 2].Font.Bold = True;
+ model[2, 2].Font.Size = 16;
+ model[2, 2].HorizontalAlignment = GridHorizontalAlignment.Center;
+ model[2, 2].VerticalAlignment = GridVerticalAlignment.Middle;
+ model[2, 2].CellType = "Static";
+ model[2, 2].Borders.All = new GridBorder(GridBorderStyle.Solid, Color.FromArgb(100, 238, 122, 3));
+ model[2, 2].Interior = new BrushInfo(GradientStyle.PathEllipse, Color.FromArgb(100, 57, 73, 122), Color.FromArgb(237, 240, 247));
+
+ If you query for specific attributes in a cell and these attributes have not been explicitly set for the cell,
+ the
+ GridStyleInfo standard = model.BaseStylesMap["Standard"].StyleInfo;
+ standard.TextColor = Color.FromArgb(0, 21, 84);
+ Color color = model[1, 1].TextColor;
+ // model[1, 1].TextColor will return Color.FromArgb(0, 21, 84));
+
+
+ //Get the grid model.
+ GridModel model = this.gridControl1.TableStyle.GetGridModel();
+
+
+ 'Get the grid model.
+ Dim model As GridModel= Me.gridControl1.TableStyle.GetGridModel()
+
+
+ this.gridControl1.Model.RowStyles[row - 1].Borders.Bottom = new GridBorder(GridBorderStyle.Solid, c, GridBorderWeight.ExtraExtraThick);
+ this.gridControl1.Model.ColStyles[col - 1].Borders.Right = new GridBorder(GridBorderStyle.Solid, c, GridBorderWeight.ExtraExtraThick);
+ GridBordersInfo b = this.gridControl1.Model[row - 1, col - 1].ReadOnlyBorders;
+ Console.WriteLine(b.Right); // will return Default since ReadOnlyBorders is RowStyles[row - 1].Borders which
+ has no knowledge about ColStyles if FixSubObjectsDerivedFromRowandColStyle = false.
+
+ Setting FixSubObjectsDerivedFromRowandColStyle = true fixes the problem.
+
+
+ //Setting the back color for GridTable.
+ this.gridControl1.TableStyle.BackColor = Color.Red;
+
+
+ 'Setting the back color for GridTable.
+ Me.gridControl1.TableStyle.BackColor = Color.Red
+
+
+ //sets how text is trimmed when it exceeds the edges of the cell text rectangle.
+ this.gridControl1.TableStyle.Trimming = StringTrimming.EllipsisPath;
+
+
+ 'sets how text is trimmed when it exceeds the edges of the cell text rectangle.
+ Me.gridControl1.TableStyle.Trimming = StringTrimming.EllipsisPath
+
+
+ //Set the character case
+ this.gridControl1.TableStyle.CharacterCasing = CharacterCasing.Upper;
+
+
+ 'Set the character case
+ Me.gridControl1.TableStyle.CharacterCasing = CharacterCasing.Upper
+
+
+ //Set the vertical alignment for text in a cell.
+ this.gridControl1.TableStyle.VerticalAlignment = GridVerticalAlignment.Middle;
+
+
+ 'Set the vertical alignment for text in a cell.
+ Me.gridControl1.TableStyle.VerticalAlignment = GridVerticalAlignment.Middle
+
+
+ this.gridControl1.TableStyle.TextAlign = GridTextAlign.Right;
+
+
+ Me.gridControl1.TableStyle.TextAlign = GridTextAlign.Right;
+
+
+ //Set the Cell Appearance.
+ this.gridControl1.TableStyle.CellAppearance = GridCellAppearance.Sunken;
+
+
+ 'Set the Cell Appearance.
+ Me.gridControl1.TableStyle.CellAppearance = GridCellAppearance.Sunken
+
+
+ //Display special characters when the contents in cell exceeds it's width.
+ this.gridControl1.TableStyle.AutoFit = AutoFitOptions.Alphabet;
+ this.gridControl1.TableStyle.AutoFit = AutoFitOptions.Numeric;
+ this.gridControl1.TableStyle.AutoFit = AutoFitOptions.Both;
+ this.gridControl1.TableStyle.AutoFit = AutoFitOptions.None;
+
+
+ 'Display special characters when the contents in cell exceeds it's width.
+ Me.gridControl1.TableStyle.AutoFit = AutoFitOptions.Alphabet
+ Me.gridControl1.TableStyle.AutoFit = AutoFitOptions.Numeric
+ Me.gridControl1.TableStyle.AutoFit = AutoFitOptions.Both
+ Me.gridControl1.TableStyle.AutoFit = AutoFitOptions.None
+
+
+ //Resets the AutoFit property.
+ this.gridControl1.TableStyle.ResetAutoFit();
+
+
+ 'Resets the AutoFit property.
+ Me.gridControl1.TableStyle.ResetAutoFit()
+
+
+ //Display special characters when the contents in cell exceeds it's width.
+ this.gridControl1.TableStyle.AutoFit = AutoFitOptions.Alphabet;
+ //Set the character to display when the contents in cell exceeds it's width.
+ this.gridControl1.TableStyle.AutoFitChar = 's';
+
+
+ 'Display special characters when the contents in cell exceeds it's width.
+ Me.gridControl1.TableStyle.AutoFit = AutoFitOptions.Alphabet
+ 'Set the character to display when the contents in cell exceeds it's width.
+ this.gridControl1.TableStyle.AutoFitChar = 's';
+
+
+ //Resets the AutoFitChar property.
+ this.gridControl1.TableStyle.ResetAutoFitChar ();
+
+
+ 'Resets the AutoFitChar property.
+ Me.gridControl1.TableStyle.ResetAutoFitChar ()
+
+
+ //Getting CultureInfo of Grid.
+ CultureInfo cultureInfo = this.gridControl1.TableStyle.GetCulture(true);
+
+
+ 'Getting CultureInfo of Grid.
+ Dim cultureInfo As CultureInfo = Me.gridControl1.TableStyle.GetCulture(True)
+
+
+ Image image = Image.FromFile(@"\...\...\FileName.jpg");
+ this.gridControl1.TableStyle.BackgroundImage = image;
+
+
+ Dim image As Image = Image.FromFile("\...\...\FileName.jpg")
+ Me.gridControl1.TableStyle.BackgroundImage = image
+
+
+ GridControl grid = new GridControl();
+ GridStyleInfo style = new GridStyleInfo();
+
+ // using ctor with existing style object and caching the object (both C# and VB)
+ MyCustomStyleProperties mcs = new MyCustomStyleProperties(style);
+ mcs.TheLocked = true;
+ mcs.TheFont.Bold = true;
+
+ // design time code (both C# and VB)
+ MyCustomStyleProperties myCustomStyleProperties1 = new MyCustomStyleProperties();
+ myCustomStyleProperties1.TheLocked = true;
+ myCustomStyleProperties1.TheFont.Bold = true;
+ style.CustomProperties.Add(myCustomStyleProperties1);
+
+ // using ctor with indexer (C# only)
+ (new MyCustomStyleProperties(grid[1,1])).TheLocked = true;
+ (new MyCustomStyleProperties(grid[1,1])).TheFont.Bold = true;
+
+ // using ctor with existing style object (C# only)
+ style.Text = "bla";
+ new MyCustomStyleProperties(style).TheLocked = true;
+ new MyCustomStyleProperties(style).TheFont.Bold = true;
+
+ // explicit case (C# only)
+ ((MyCustomStyleProperties) style).TheLocked = true;
+ ((MyCustomStyleProperties) style).TheFont.Bold = true;
+
+
+ Dim style As New GridStyleInfo()
+ Dim grid As New GridControl()
+
+ ' using ctor with existing style object and caching the object (VB and C#)
+ Dim mcs As New MyCustomStyleProperties(style)
+ mcs.TheLocked = True
+ mcs.TheFont.Bold = True
+
+ ' design time code (VB and C#)
+ Dim myCustomStyleProperties1 As New MyCustomStyleProperties()
+ myCustomStyleProperties1.TheLocked = True
+ myCustomStyleProperties1.TheFont.Bold = True
+ style.CustomProperties.Add(myCustomStyleProperties1)
+
+ ' with operator (Visual Basic only)
+ With New MyCustomStyleProperties(style)
+ .TheLocked = True
+ .TheFont.Bold = True
+ End With
+
+ ' with operator (Visual Basic only)
+ With New MyCustomStyleProperties(grid(1, 1))
+ .TheLocked = True
+ .TheFont.Bold = True
+ End With
+
+
+ using System;
+ using System.ComponentModel;
+
+ using Syncfusion.Diagnostics;
+ using Syncfusion.Styles;
+ using Syncfusion.Windows.Forms;
+ using Syncfusion.Windows.Forms.Grid;
+
+ namespace WindowsApplication1
+ {
+ public class MyCustomStyleProperties : GridStyleInfoCustomProperties
+ {
+ // static initialization of property descriptors
+ static Type t = typeof(MyCustomStyleProperties);
+
+ readonly static StyleInfoProperty LockedProperty = CreateStyleInfoProperty(t, "TheLocked");
+ readonly static StyleInfoProperty TheFontProperty = CreateStyleInfoProperty(t, "TheFont");
+
+ // default settings for all properties this object holds
+ static MyCustomStyleProperties defaultObject;
+
+ // initialize default settings for all properties in static ctor
+ static MyCustomStyleProperties ()
+ {
+ // all properties must be initialized for the Default property
+ defaultObject = new MyCustomStyleProperties(GridStyleInfo.Default);
+ defaultObject.TheLocked = true;
+ defaultObject.TheFont = GridFontInfo.Default;
+ }
+
+ ///
+ /// Provides access to default values for this type.
+ ///
+ public static MyCustomStyleProperties Default
+ {
+ get
+ {
+ return defaultObject;
+ }
+ }
+
+ ///
+ /// Force static ctor being called at least once.
+ ///
+ public static void Initialize()
+ {
+ }
+
+ // Explicit cast from GridStyleInfo to MyCustomStyleProperties.
+ // (Note: this will only work for C#, Visual Basic does not support dynamic casts.)
+
+ ///
+ /// Explicit cast from GridStyleInfo to this custom property object.
+ ///
+ /// A new custom properties object.
+ public static explicit operator MyCustomStyleProperties(GridStyleInfo style)
+ {
+ return new MyCustomStyleProperties(style);
+ }
+
+ ///
+ /// Initializes a MyCustomStyleProperties object with a style object that holds all data.
+ ///
+ public MyCustomStyleProperties(GridStyleInfo style)
+ : base(style)
+ {
+ }
+
+ ///
+ /// Initializes a MyCustomStyleProperties object with an empty style object. Design-
+ /// time environment will use this ctor and later copy the values to a style object
+ /// by calling style.CustomProperties.Add(otherCustomStyleProperties1).
+ ///
+ public MyCustomStyleProperties()
+ : base()
+ {
+ }
+
+ ///
+ /// Gets / sets TheLocked state.
+ ///
+ [
+ Description("Specifies if ..."),
+ Browsable(true),
+ Category("StyleCategoryBehavior")
+ ]
+ public bool TheLocked
+ {
+ get
+ {
+ TraceUtil.TraceCurrentMethodInfo();
+ return (bool) style.GetValue(LockedProperty);
+ }
+ set
+ {
+ TraceUtil.TraceCurrentMethodInfo(value);
+ style.SetValue(LockedProperty, value);
+ }
+ }
+ ///
+ /// Resets TheLocked state.
+ ///
+ public void ResetTheLocked()
+ {
+ style.ResetValue(LockedProperty);
+ }
+ [EditorBrowsableAttribute(EditorBrowsableState.Never)]
+ private bool ShouldSerializeTheLocked()
+ {
+ return style.HasValue(LockedProperty);
+ }
+ ///
+ /// Gets if TheLocked state has been initialized for the current object.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool HasTheLocked
+ {
+ get
+ {
+ return style.HasValue(LockedProperty);
+ }
+ }
+
+ ///
+ /// Gets / sets TheFont state. TheFont is itself an expandable object
+ /// with several properties that can be set individually and participate
+ /// in style inheritance mechanism.
+ ///
+ [
+ Description("The font for drawing text."),
+ Browsable(true),
+ DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
+ Category("StyleCategoryAppearance")
+ ]
+ public GridFontInfo TheFont
+ {
+ get
+ {
+ return (GridFontInfo) style.GetValue(TheFontProperty);
+ }
+ set
+ {
+ style.SetValue(TheFontProperty, value);
+ }
+ }
+
+ ///
+ /// Resets TheFont state.
+ ///
+ public void ResetTheFont()
+ {
+ style.ResetValue(TheFontProperty);
+ }
+ [EditorBrowsableAttribute(EditorBrowsableState.Never)]
+ private bool ShouldSerializeTheFont()
+ {
+ return style.HasValue(TheFontProperty);
+ }
+ ///
+ /// Determines if TheFont state has been initialized for the current object.
+ ///
+ [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public bool HasTheFont
+ {
+ get
+ {
+ return style.HasValue(TheFontProperty);
+ }
+ }
+
+ }
+
+ public class MyGridControl : GridControl
+ {
+ public MyGridControl()
+ {
+ // force static ctor of MyCustomStyleProperties being called at least once
+ MyCustomStyleProperties.Initialize();
+ }
+ }
+ }
+
+
+ Public Class MyCustomStyleProperties
+ Inherits GridStyleInfoCustomProperties
+ ' static initialization of property descriptors
+ Private Shared t As Type = GetType(MyCustomStyleProperties)
+
+ Private Shared LockedProperty As StyleInfoProperty = CreateStyleInfoProperty(t, "TheLocked")
+ Private Shared TheFontProperty As StyleInfoProperty = CreateStyleInfoProperty(t, "TheFont")
+
+ ' default settings for all properties this object holds
+ Private Shared defaultObject As MyCustomStyleProperties
+
+
+ ' initialize default settings for all properties in static ctor
+ Shared Sub New()
+ ' all properties must be initialized for the Default property
+ defaultObject = New MyCustomStyleProperties(GridStyleInfo.Default)
+ defaultObject.TheLocked = True
+ defaultObject.TheFont = GridFontInfo.Default
+ End Sub 'New
+
+ '/
+ '/ Provides access to default values for this type
+ '/
+
+ Public Shared ReadOnly Property [Default]() As MyCustomStyleProperties
+ Get
+ Return defaultObject
+ End Get
+ End Property
+
+
+ '/
+ '/ Force static ctor being called at least once.
+ '/
+ Public Shared Sub Initialize()
+ End Sub 'Initialize
+
+ '/
+ '/ Initializes a MyCustomStyleProperties object with a style object that holds all data.
+ '/
+ Public Sub New(ByVal style As GridStyleInfo)
+ MyBase.New(style)
+ End Sub 'New
+
+
+ '/
+ '/ Initializes a MyCustomStyleProperties object with an empty style object. Design-
+ '/ time environment will use this ctor and later copy the values to a style object
+ '/ by calling style.CustomProperties.Add(otherCustomStyleProperties1).
+ '/
+ Public Sub New()
+ End Sub 'New
+
+ '/
+ '/ Gets / sets TheLocked state.
+ '/
+
+ 'Description("Specifies if ..."), Browsable(True), Category("StyleCategoryBehavior")> _
+ Public Property TheLocked() As Boolean
+ Get
+ TraceUtil.TraceCurrentMethodInfo()
+ Return CBool(style.GetValue(LockedProperty))
+ End Get
+ Set(ByVal Value As Boolean)
+ TraceUtil.TraceCurrentMethodInfo(Value)
+ style.SetValue(LockedProperty, Value)
+ End Set
+ End Property
+
+ '/
+ '/ Resets TheLocked state.
+ '/
+ Public Sub ResetTheLocked()
+ style.ResetValue(LockedProperty)
+ End Sub 'ResetTheLocked
+
+ 'EditorBrowsableAttribute(EditorBrowsableState.Never)> _
+ Private Function ShouldSerializeTheLocked() As Boolean
+ Return style.HasValue(LockedProperty)
+ End Function 'ShouldSerializeTheLocked
+ '/
+ '/ Gets if TheLocked state has been initialized for the current object.
+ '/
+
+ 'Browsable(False), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
+ Public ReadOnly Property HasTheLocked() As Boolean
+ Get
+ Return style.HasValue(LockedProperty)
+ End Get
+ End Property
+
+ '/
+ '/ Gets / sets TheFont state. TheFont is itself an expandable object
+ '/ with several properties that can be set individually and participate
+ '/ in style inheritance mechanism.
+ '/
+
+ 'Description("The font for drawing text."), Browsable(True), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Category("StyleCategoryAppearance")> _
+ Public Property TheFont() As GridFontInfo
+ Get
+ Return CType(style.GetValue(TheFontProperty), GridFontInfo)
+ End Get
+ Set(ByVal Value As GridFontInfo)
+ style.SetValue(TheFontProperty, Value)
+ End Set
+ End Property
+
+
+ '/
+ '/ Resets TheFont state.
+ '/
+ Public Sub ResetTheFont()
+ style.ResetValue(TheFontProperty)
+ End Sub 'ResetTheFont
+
+ 'EditorBrowsableAttribute(EditorBrowsableState.Never)> _
+ Private Function ShouldSerializeTheFont() As Boolean
+ Return style.HasValue(TheFontProperty)
+ End Function 'ShouldSerializeTheFont
+ '/
+ '/ Determines if TheFont state has been initialized for the current object.
+ '/
+
+ 'Browsable(False), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
+ Public ReadOnly Property HasTheFont() As Boolean
+ Get
+ Return style.HasValue(TheFontProperty)
+ End Get
+ End Property
+ End Class 'MyCustomStyleProperties
+
+
+ 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"
+
+
+ //Get the grid model.
+ GridModel model = this.gridControl1.TableStyle.GetGridModel();
+
+
+ 'Get the grid model.
+ Dim model As GridModel= Me.gridControl1.TableStyle.GetGridModel()
+
+
+ protected virtual Control CreateInnerControl(out GridControlBase grid)
+ {
+ grid = Grid.CreateNewControl(this.dropdownContainer, 0, 0) as GridControlBase;
+ grid.Dock = DockStyle.Fill;
+
+ grid.DropDownContainerParent = this.dropdownContainer;
+
+ GridRecordNavigationControl recordNavigationControl1 = null;
+ recordNavigationControl1 = new GridRecordNavigationControl (grid);
+ recordNavigationControl1.Dock = DockStyle.Fill;
+ recordNavigationControl1.TabIndex = 0;
+ return recordNavigationControl1;
+ }
+
+
+ GridNumericUpDownCellModel cm = (GridNumericUpDownCellModel) this.gridControl1.CellModels["NumericUpDown"];
+ cm.AcceptAlphaKeys = false;
+
+
+ Dim cm As GridNumericUpDownCellModel = CType(Me.gridControl1.CellModels("NumericUpDown"), GridNumericUpDownCellModel)
+ cm.AcceptAlphaKeys = False
+
+
+ // Resizing and selecting functionality of row and column will be enabled for grid. Other functionalities like Clicking, OleDropTarget ..etc will not be worked.
+ this.gridControl1.ControllerOptions = GridControllerOptions.ResizeCells | GridControllerOptions.SelectCells;
+
+
+ ' Resizing and selecting functionality of row and column will be enabled for grid. Other functionalities like Clicking, OleDropTarget ..etc will not be worked.
+ Me.gridControl1.ControllerOptions = (GridControllerOptions.ResizeCells Or GridControllerOptions.SelectCells)
+
+
+ // TextColor for all the grid cells will be changed to Blue
+ this.gridControl1.BaseStylesMap["Standard"].StyleInfo.TextColor = Color.Blue;
+ // Backcolor for all the header cells (Row and Column) will be changed as "Red"
+ this.gridControl1.BaseStylesMap["Header"].StyleInfo.BackColor = Color.Red;
+
+
+ ' TextColor for all the grid cells will be changed to Blue
+ Me.gridControl1.BaseStylesMap["Standard"].StyleInfo.TextColor = Color.Blue
+ ' Backcolor for all the header cells (Row and Column) will be changed as "Red"
+ Me.gridControl1.BaseStylesMap["Header"].StyleInfo.BackColor = Color.Red
+
+
+ // Hiding the first row.
+ this.gridControl1.HideRows[1] = true;
+ // Removing the first row from hidden.
+ this.gridControl1.HideRows [3] = false;
+
+
+ ' Hiding the first row.
+ Me.gridControl1.HideRows[1] = true
+ ' Removing the first row from hidden.
+ Me.gridControl1.HideRows [3] = false
+
+
+ // Hiding the first column.
+ this.gridControl1.HideCols[1] = true;
+ // Removing the second column from hidden.
+ this.gridControl1.HideCols[4] = false;
+
+
+ ' Hiding the first column.
+ Me.gridControl1.HideCols[1] = true
+ ' Removing the second column from hidden.
+ Me.gridControl1.HideCols[4] = false
+
+
+ // Undo the actions in the grid.
+ this.gridControl1.CommandStack.Undo();
+ //Redo the actions in the grid.
+ this.gridControl1.CommandStack.Redo();
+ // Getting the current command mode of the grid.
+ GridCommandMode commandMode = this.gridControl1.CommandStack.Mode;
+
+
+ ' Undo the actions in the grid.
+ Me.gridControl1.CommandStack.Undo()
+ ' Redo the actions in the grid.
+ Me.gridControl1.CommandStack.Redo()
+ ' Getting the current command mode of the grid.
+ Dim commandMode As GridCommandMode = Me.gridControl1.CommandStack.Mode
+
+
+ // Setting whole column's styles.
+ this.gridControl1.ColStyles[1].BackColor = Color.Red;
+ this.gridControl1.ColStyles[1].Font.Facename = "Segoe UI";
+ this.gridControl1.ColStyles[1].Font.Bold = true;
+
+
+ ' Setting whole column's styles.
+ Me.gridControl1.ColStyles[1].BackColor = Color.Red
+ Me.gridControl1.ColStyles[1].Font.Facename = "Segoe UI"
+ Me.gridControl1.ColStyles[1].Font.Bold = true
+
+
+ // Setting styles for the whole row with the specific row index.
+ this.gridControl1.RowStyles[1].BackColor = Color.Red;
+ this.gridControl1.RowStyles[1].Font.Facename = "Segoe UI";
+ this.gridControl1.RowStyles[1].Font.Bold = true;
+
+
+ ' Setting styles for the whole row with the specific row index.
+ Me.gridControl1.RowStyles(1).BackColor = Color.Red
+ Me.gridControl1.RowStyles(1).Font.Facename = "Segoe UI"
+ Me.gridControl1.RowStyles(1).Font.Bold = true
+
+
+ this.gridControl1.TableStyle.TextColor = Color.Red;
+ this.gridControl1.TableStyle.Font.Facename = "Segoe UI";
+ this.gridControl1.TableStyle.Font.Size = 15;
+
+
+ Me.gridControl1.TableStyle.TextColor = Color.Red
+ Me.gridControl1.TableStyle.Font.Facename = "Segoe UI"
+ Me.gridControl1.TableStyle.Font.Size = 15
+
+
+ // Defining the covered range.
+ GridRangeInfo coveredRange = GridRangeInfo.Cells(1, 2, 5, 5);
+ // Adding the range to be covered.
+ this.gridControl1.CoveredRanges.Add(coveredRange);
+
+
+ ' Defining the covered range.
+ Dim coveredRange As GridRangeInfo = GridRangeInfo.Cells(1, 2, 5, 5)
+ ' Adding the range to be covered.
+ Me.gridControl1.CoveredRanges.Add(coveredRange)
+
+
+ //Specify the cell model to be added in the grid model with cell type name.
+ this.gridControl1.CellModels.Add("SampleCellType", new GridHeaderCellModel(this.gridControl1.Model));
+ // Set the added cell type to the cell.
+ this.gridControl1.ColStyles[1].CellType = "SampleCellType";
+
+
+ ' Specify the cell model to be added in the grid model with cell type name.
+ Me.gridControl1.CellModels.Add("SampleCellType", new GridHeaderCellModel(this.gridControl1.Model))
+ ' Set the added cell type to the cell.
+ Me.gridControl1.ColStyles[1].CellType = "SampleCellType"
+
+
+ // Setting the mouse button mask to drag either using Left or Right mouse button.
+ this.gridControl1.DragSelectedCellsMouseButtonsMask = System.Windows.Forms.MouseButtons.Left | System.Windows.Forms.MouseButtons.Right;
+
+
+ ' Setting the mouse button mask to drag either using Left or Right mouse button.
+ Me.gridControl1.DragSelectedCellsMouseButtonsMask = (System.Windows.Forms.MouseButtons.Left Or System.Windows.Forms.MouseButtons.Right)
+
+
+ // Setting grid's selection mode as MultiExtended
+ this.gridControl1.ListBoxSelectionMode = SelectionMode.MultiExtended;
+
+
+ ' Setting grid control selection mode as MultiExtended
+ Me.gridControl1.ListBoxSelectionMode = SelectionMode.MultiExtended
+
+
+ // Current cell will be activated when clicking on a cell.
+ this.gridControl1.ActivateCurrentCellBehavior = GridCellActivateAction.ClickOnCell;
+
+
+ ' Current cell will be activated when clicking on a cell.
+ Me.gridControl1.ActivateCurrentCellBehavior = GridCellActivateAction.ClickOnCell
+
+
+ // Moves the current cell to the bottom when pressing Enter key.
+ this.gridControl1.EnterKeyBehavior = GridDirectionType.Bottom;
+
+
+ ' Moves the current cell to the bottom when pressing Enter key.
+ Me.gridControl1.EnterKeyBehavior = GridDirectionType.Bottom
+
+
+ //Current cell border will always visible
+ this.gridControl1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.AlwaysVisible;
+
+
+ 'Current cell border will always visible
+ Me.gridControl1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.AlwaysVisible
+
+
+ // Populating DataSource
+ DataTable dataTable = new DataTable("Sample");
+ dataTable.Columns.Add("Column 1");
+ dataTable.Columns.Add("Column 2");
+ dataTable.Columns.Add("Column 3");
+ dataTable.Columns.Add("Column 4");
+ dataTable.Rows.Add("Row1", "Row2", "Row3", "Row4");
+
+ Populating the values to grid.
+ this.gridControl1.PopulateValues(GridRangeInfo.Cells(1, 1, dataTable.Rows.Count, dataTable.Columns.Count), dataTable);
+
+
+ ' Populating DataSource
+ Dim dataTable As DataTable = New DataTable("Sample")
+ dataTable.Columns.Add("Column 1")
+ dataTable.Columns.Add("Column 2")
+ dataTable.Columns.Add("Column 3")
+ dataTable.Columns.Add("Column 4")
+ dataTable.Rows.Add("Row1", "Row2", "Row3", "Row4")
+
+ 'Populating the values to grid.
+ this.gridControl1.PopulateValues(GridRangeInfo.Cells(1, 1, dataTable.Rows.Count, dataTable.Columns.Count), dataTable)
+
+
+ // Populating DataSource
+ DataTable dataTable = new DataTable("Sample");
+ dataTable.Columns.Add("Column 1");
+ dataTable.Columns.Add("Column 2");
+ dataTable.Columns.Add("Column 3");
+ dataTable.Columns.Add("Column 4");
+ dataTable.Rows.Add("Row1", "Row2", "Row3", "Row4");
+
+ //Populating the headers
+ this.gridControl1.PopulateHeaders(GridRangeInfo.Cells(0, 1, 0, 4), dataTable);
+
+
+ ' Populating DataSource
+ Dim dataTable As DataTable = New DataTable("Sample")
+ dataTable.Columns.Add("Column 1")
+ dataTable.Columns.Add("Column 2")
+ dataTable.Columns.Add("Column 3")
+ dataTable.Columns.Add("Column 4")
+ dataTable.Rows.Add("Row1", "Row2", "Row3", "Row4")
+
+ ' Populating the headers
+ Me.gridControl1.PopulateHeaders(GridRangeInfo.Cells(0, 1, 0, 4), dataTable)
+
+
+ // The target range to set the text.
+ GridRangeInfo range = GridRangeInfo.Cols(1, 2);
+
+ //Setting the "SampleData" text to target range.
+ this.gridControl1.ChangeCells(range, "SampleData");
+
+
+ ' The target range to set the text.
+ Dim range As GridRangeInfo = GridRangeInfo.Cols(1, 2)
+
+ 'Setting the "SampleData" text to target range.
+ Me.gridControl1.ChangeCells(range, "SampleData")
+
+
+ // Defining the new cell styles.
+ GridStyleInfo newStyle = new GridStyleInfo();
+ newStyle.CellType = GridCellTypeName.ComboBox;
+ // Setting the styles of range of cells to new style.
+ this.gridControl1.ChangeCells(GridRangeInfo.Rows(1, 2), newStyle);
+
+
+ ' Defining the new cell styles.
+ Dim newStyle As GridStyleInfo = New GridStyleInfo
+ newStyle.CellType = GridCellTypeName.ComboBox
+ // Setting the styles of range of cells to new style.
+ Me.gridControl1.ChangeCells(GridRangeInfo.Rows(1, 2), newStyle)
+
+
+ // Defining the new cell styles.
+ GridStyleInfo newStyle = new GridStyleInfo();
+ newStyle.CellType = GridCellTypeName.ComboBox;
+ // Setting the styles of range of cells to new style.
+ this.gridControl1.ChangeCells(GridRangeInfo.Rows(1, 2), newStyle, Syncfusion.Styles.StyleModifyType.Changes);
+
+
+ Dim newStyle As GridStyleInfo = New GridStyleInfo
+ newStyle.CellType = GridCellTypeName.ComboBox
+ ' Setting the styles of range of cells to new style.
+ Me.gridControl1.ChangeCells(GridRangeInfo.Rows(1, 2), newStyle, Syncfusion.Styles.StyleModifyType.Changes)
+
+
+ // Defining the new cell styles.
+ GridStyleInfo newStyle = new GridStyleInfo();
+ newStyle.CellType = GridCellTypeName.ComboBox;
+ // Setting the styles of range of cells to new style.
+ this.gridControl1.ChangeCells(GridRangeInfo.Rows(1, 2), newStyle, Syncfusion.Styles.StyleModifyType.Changes);
+
+
+ ' Defining the new cell styles.
+ Dim newStyle As GridStyleInfo = New GridStyleInfo
+ newStyle.CellType = GridCellTypeName.ComboBox
+ ' Setting the styles of range of cells to new style.
+ Me.gridControl1.ChangeCells(GridRangeInfo.Rows(1, 2), newStyle, Syncfusion.Styles.StyleModifyType.Changes)
+
+
+ GridStyleInfo style1 = new GridStyleInfo();
+ style1.TextColor = Color.Blue;
+ GridStyleInfo style2 = new GridStyleInfo();
+ style2.BackColor = Color.Red;
+ GridStyleInfo[] styles = new GridStyleInfo[] { style1, style2 };
+ GridRangeInfo range = GridRangeInfo.Rows(1,2);
+ this.gridControl1.ChangeCells(range, styles, Syncfusion.Styles.StyleModifyType.Remove);
+
+
+ Dim style1 As GridStyleInfo = New GridStyleInfo
+ style1.TextColor = Color.Blue
+ Dim style2 As GridStyleInfo = New GridStyleInfo
+ style2.BackColor = Color.Red
+ Dim styles() As GridStyleInfo = New GridStyleInfo() {style1, style2}
+ Dim range As GridRangeInfo = GridRangeInfo.Rows(1, 2)
+ Me.gridControl1.ChangeCells(range, styles, Syncfusion.Styles.StyleModifyType.Remove)
+
+
+ // Sets back-color depending on the index.
+ this.gridDataBoundGrid1.Model.ColStyles[1].BackColor = Color.Red;
+
+
+ ' Sets back-color depending on the index.
+ Me.gridDataBoundGrid1.Model.ColStyles(1).BackColor = Color.Red
+
+
+ // Creates a column collection to be added to the grid.
+ GridBoundColumnsCollection myColumn = (GridBoundColumnsCollection)this.gridDataBoundGrid1.Binder.InternalColumns.Clone();
+ // Creates the column to be added.
+ GridBoundColumn Column1 = new GridBoundColumn();
+ Column1.HeaderText = "NewColumn";
+ // Adds the created column to the collection.
+ myColumn.Add(Column1);
+ // Binds the created column collections to the grid bound columns.
+ this.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn;
+
+
+ ' Creates a column to be added to the collection.
+ Dim myColumn1 As GridBoundColumnsCollection = CType(Me.gridDataBoundGrid1.Binder.InternalColumns.Clone(), GridBoundColumnsCollection)
+ Dim Column1 As New GridBoundColumn()
+ Column1.HeaderText = "NewColumn"
+ myColumn1.Add(Column1)
+ ' Binds the created column to the grid bound columns.
+ Me.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn1
+
+
+ // Creates a column collection to be added to the grid.
+ GridBoundColumnsCollection myColumn = (GridBoundColumnsCollection)this.gridDataBoundGrid1.Binder.InternalColumns.Clone();
+ // Declares the range of columns to be added.
+ GridBoundColumn[] Column1 = new GridBoundColumn[5];
+ // Initializes each instance of the GridBoundColumns.
+
+ Column1[i] = new GridBoundColumn();
+ Column1[0].HeaderText = "NewColumn 1";
+ Column1[1].HeaderText = "NewColumn 2";
+ Column1[2].HeaderText = "NewColumn 3";
+ Column1[3].HeaderText = "NewColumn 4";
+ Column1[4].HeaderText = "NewColumn 5";
+ // Binds the created column collections to the grid bound columns.
+ myColumn.AddRange(Column1);
+ this.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn;
+
+
+ ' Creates a column collection to be added to the grid.
+ Dim myColumn As GridBoundColumnsCollection = CType(Me.gridDataBoundGrid1.Binder.InternalColumns.Clone(), GridBoundColumnsCollection)
+ ' Declares the range of columns to be added.
+ Dim Column1(4) As GridBoundColumn
+ ' Initializes each instance of the GridBoundColumns.
+ For i As Integer = 0 To Column1.Length - 1
+ Column1(i) = New GridBoundColumn()
+ Next i
+ Column1(0).HeaderText = "NewColumn 1"
+ Column1(1).HeaderText = "NewColumn 2"
+ Column1(2).HeaderText = "NewColumn 3"
+ Column1(3).HeaderText = "NewColumn 4"
+ Column1(4).HeaderText = "NewColumn 5"
+ ' Binds the created column collections to the grid bound columns.
+ myColumn.AddRange(Column1)
+ Me.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn
+
+
+ // Creates a column collection to be added to the grid.
+ GridBoundColumnsCollection myColumn = (GridBoundColumnsCollection)this.gridDataBoundGrid1.Binder.InternalColumns.Clone();
+ // Creates the column to be added.
+ GridBoundColumn Column1 = new GridBoundColumn();
+ Column1.HeaderText = "NewColumn";
+ // Inserts the created column to the collection at the specified index of the grid. Here "3" is the column index.
+ myColumn.Insert(3, Column1);
+ // Binds the created column collections to the grid bound columns.
+ this.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn;
+
+
+ ' Creates a column collection to be added to the grid.
+ Dim myColumn As GridBoundColumnsCollection = CType(Me.gridDataBoundGrid1.Binder.InternalColumns.Clone(), GridBoundColumnsCollection)
+ ' Creates the column to be added.
+ Dim Column1 As New GridBoundColumn()
+ Column1.HeaderText = "NewColumn"
+ ' Inserts the created column to the collection at the specified index of the grid. Here "3" is the column index.
+ myColumn.Insert(3, Column1)
+ ' Binds the created column collections to the grid bound columns.
+ Me.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn
+
+
+ // Removes the column using GridBoundColumn mapping name.
+ this.gridDataBoundGrid1.Binder.InternalColumns.Remove(Column1);
+
+
+ ' Removes the column using GridBoundColumn mapping name.
+ Me.gridDataBoundGrid1.Binder.InternalColumns.Remove(Column1)
+
+
+ // Removes column at the given index in the grid. Here "3" is the column index.
+ this.gridDataBoundGrid1.Binder.InternalColumns.RemoveAt(3);
+
+
+ ' Removes column at the given index in the grid. Here "3" is the column index.
+ Me.gridDataBoundGrid1.Binder.InternalColumns.RemoveAt(3)
+
+
+ // Sets the border line style
+ this.gridDataBoundGrid1.DefaultGridBorderStyle = GridBorderStyle.Solid;
+
+
+ ' Sets the border line style
+ Me.gridDataBoundGrid1.DefaultGridBorderStyle = GridBorderStyle.Solid
+
+
+ // Sets the color of grid lines.
+ this.gridDataBoundGrid1.GridLineColor = Color.Red;
+
+
+ ' Sets the color of grid lines.
+ Me.gridDataBoundGrid1.GridLineColor = Color.Red
+
+
+ public override Control CreateNewControl(Control parent, int row, int column)
+ {
+ MyGridDataBoundGrid grid = new MyGridDataBoundGrid((GridDataBoundGridModel) this.Model);
+ this.WireNewControl(grid);
+ return grid;
+ }
+
+
+ // Creates a column to be added to the collection.
+ GridBoundColumnsCollection myColumn1 = (GridBoundColumnsCollection)this.gridDataBoundGrid1.Binder.InternalColumns.Clone();
+ GridBoundColumn Column1 = new GridBoundColumn();
+ Column1.HeaderText = "NewColumn";
+ myColumn1.Add(Column1);
+ // Binds the created column to the grid bound columns.
+ this.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn1;
+
+
+ ' Creates a column to be added to the collection.
+ Dim myColumn1 As GridBoundColumnsCollection = CType(Me.gridDataBoundGrid1.Binder.InternalColumns.Clone(), GridBoundColumnsCollection)
+ Dim Column1 As New GridBoundColumn()
+ Column1.HeaderText = "NewColumn"
+ myColumn1.Add(Column1)
+ ' Binds the created column to the grid bound columns.
+ Me.gridDataBoundGrid1.Binder.GridBoundColumns = myColumn1
+
+
+ // Creates the data source.
+ DataTable dataTable = new DataTable();
+ // Assigns the data source to be displayed in the grid
+ this.gridDataBoundGrid1.DataSource = dataTable;
+
+
+ ' Creates the data source.
+ Dim dataTable As New DataTable()
+ ' Assigns the data source to be displayed in the grid
+ Me.gridDataBoundGrid1.DataSource = dataTable
+
+
+ private void gridDataBoundGrid3_ValidateFailed(object sender, GridValidateFailedEventArgs e)
+ {
+ TraceUtil.TraceCurrentMethodInfo(e);
+ GridCurrentCell cc = this.gridDataBoundGrid3.CurrentCell;
+ cc.Grid.CancelUpdate();
+ MessageBox.Show("My Error:" + cc.ErrorMessage);
+ cc.RejectChanges();
+ cc.ResetError();
+ }
+
+
+ // Sets the sorting behavior
+ this.gridDataBoundGrid1.SortBehavior = GridSortBehavior.DoubleClick;
+
+
+ ' Sets the sorting behavior
+ Me.gridDataBoundGrid1.SortBehavior = GridSortBehavior.DoubleClick
+
+
+ // Deletes the records to a specific range.
+ this.gridDataBoundGrid1.DeleteRecordsAtRowIndex(5,10);
+
+
+ ' Deletes the records to a specific range.
+ Me.gridDataBoundGrid1.DeleteRecordsAtRowIndex(5,10)
+
+
+ // Sets the current cell activation on double-clicking the cell.
+ this.gridDataBoundGrid1.ActivateCurrentCellBehavior = GridCellActivateAction.DblClickOnCell;
+
+
+ ' Sets the current cell activation on double-clicking the cell.
+ Me.gridDataBoundGrid1.ActivateCurrentCellBehavior = GridCellActivateAction.DblClickOnCell
+
+
+ // Assigns a specific color for alpha-blend selection color
+ this.gridDataBoundGrid1.AlphaBlendSelectionColor = Color.SteelBlue;
+
+
+ ' Assigns a specific color for alpha-blend selection color
+ Me.gridDataBoundGrid1.AlphaBlendSelectionColor = Color.SteelBlue
+
+
+ // Allows the selection of rows.
+ this.gridDataBoundGrid1.AllowSelection = GridSelectionFlags.Row;
+ // Disables the selection.
+ this.gridDataBoundGrid1.AllowSelection = GridSelectionFlags.None;
+
+
+ ' Allows the selection of rows.
+ Me.gridDataBoundGrid1.AllowSelection = GridSelectionFlags.Row
+ ' Disables the selection.
+ Me.gridDataBoundGrid1.AllowSelection = GridSelectionFlags.None
+
+
+ // To apply visual styles the themes enabled property should be set to true.
+ // Otherwise the default SystemTheme is applied.
+ this.gridDataBoundGrid1.ThemesEnabled = true;
+ // Applies the metro style to the grid.
+ this.gridDataBoundGrid1.GridVisualStyles = GridVisualStyles.Metro;
+
+
+ ' Otherwise the default SystemTheme is applied.
+ ' To apply visual styles the themes enabled property should be set to True
+ Me.gridDataBoundGrid1.ThemesEnabled = True
+ ' Applies the metro style to the grid.
+ Me.gridDataBoundGrid1.GridVisualStyles = GridVisualStyles.Metro
+
+
+ // Sets the selection mode of the control.
+ this.gridDataBoundGrid1.ListBoxSelectionMode = SelectionMode.MultiExtended;
+
+
+ ' Sets the selection mode of the control.
+ Me.gridDataBoundGrid1.ListBoxSelectionMode = SelectionMode.MultiExtended
+
+
+ // Only resizes the selected column or range.
+ this.gridDataBoundGrid1.ResizeColsBehavior = GridResizeCellsBehavior.ResizeSingle;
+ // Restrict resizing columns and the divider doesn't appear.
+ this.gridDataBoundGrid1.ResizeColsBehavior = GridResizeCellsBehavior.None;
+
+
+ ' Only resizes the selected column or range.
+ Me.gridDataBoundGrid1.ResizeColsBehavior = GridResizeCellsBehavior.ResizeSingle
+ ' Restrict resizing columns and the divider doesn't appear.
+ Me.gridDataBoundGrid1.ResizeColsBehavior = GridResizeCellsBehavior.None
+
+
+ // Shows the cell border like active current cell all the time.
+ this.gridDataBoundGrid1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.AlwaysVisible;
+ // Shows gray color border when the grid is not active.
+ this.gridDataBoundGrid1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.GrayWhenLostFocus;
+
+
+ ' Shows the cell border like active current cell all the time.
+ Me.gridDataBoundGrid1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.AlwaysVisible
+ ' Shows gray color border when the grid is not active.
+ Me.gridDataBoundGrid1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.GrayWhenLostFocus
+
+
+ //Show my own custom filter.
+ private void GridFilterBarShowDialogEventHandler(object send, GridFilterBarShowDialogEventArgs e)
+ {
+ MyFilterDialog dlg = new MyFilterDialog();
+ DialogResult result = dlg.ShowDialog();
+
+ if(result == DialogResult.Ignore)
+ {
+ //Show the default dialog.
+ e.Handled = false;
+ }
+ else
+ {
+ //Otherwise, don't show default and set the result.
+ e.Handled = true;
+ e.Result = result; //cancel or OK-filter the grid with e.FilterCriteria
+ e.FilterCriteria = dlg.textBox1.Text; // the filter string
+ }
+ }
+
+
+ // Creates the filter-bar instance.
+ GridFilterBar myFilterBar = new GridFilterBar();
+ // Wires the grid to the filter-bar.
+ myFilterBar.WireGrid(this.gridDataBoundGrid1);
+
+
+ ' Creates the filter-bar instance.
+ Dim myFilterBar As New GridFilterBar()
+ ' Wires the grid to the filter-bar.
+ myFilterBar.WireGrid(Me.gridDataBoundGrid1)
+
+
+ // Creates the filter-bar instance.
+ GridFilterBar myFilterBar = new GridFilterBar();
+ // Creates the GridStyleinfo instance and specifies the style properties.
+ GridStyleInfo myStyle1 = new GridStyleInfo();
+ myStyle1.BackColor = Color.WhiteSmoke;
+ myStyle1.Font.Italic = true;
+ myStyle1.Borders.All = new GridBorder(GridBorderStyle.Dashed);
+ myStyle1.ExclusiveChoiceList = true;
+ myStyle1.CellType = "ComboBox";
+ myStyle1.BaseStyle = "Standard";
+ myFilterBar.WireGrid(this.gridDataBoundGrid1, myStyle1);
+
+
+ ' Creates the filter-bar instance.
+ Dim myFilterBar As New GridFilterBar()
+ ' Creates the GridStyleinfo instance and specifies the style properties.
+ Dim myStyle1 As New GridStyleInfo()
+ myStyle1.BackColor = Color.WhiteSmoke
+ myStyle1.Font.Italic = True
+ myStyle1.Borders.All = New GridBorder(GridBorderStyle.Dashed)
+ myStyle1.ExclusiveChoiceList = True
+ myStyle1.CellType = "ComboBox"
+ myStyle1.BaseStyle = "Standard"
+ myFilterBar.WireGrid(Me.gridDataBoundGrid1, myStyle1)
+
+
+ public string[] GridFilterBarStrings = new string[]
+ {
+ "(none)", //0
+ "(custom)", //1
+ "equals", //2
+ "does not equal", //3
+ "is greater than", //4
+ "is greater than or equal to", //5
+ "is less than", //6
+ "is less than or equal to", //7
+ "begins with", //8
+ "does not begin with", //9
+ "ends with", //10
+ "does not end with", //11
+ "contains", //12
+ "does not contain", //13
+ "Use * to represent any series of characters", //14
+ "Show rows where:", //15
+ "Improper custom filter: ", //16
+ "I and " //17
+ };
+
+
+ ///
+ /// A specialization of the GridBoundColumn class with additional
+ /// functionality.
+ ///
+ public class CustomGridColumn : GridBoundColumn, ICloneable
+ {
+ private int width;
+ private int widthPercentage;
+
+ ///
+ /// Default constructor.
+ ///
+ public CustomGridColumn()
+ {
+ }
+
+ public int Width
+ {
+ get { return width; }
+ set { width = value; }
+ }
+
+ public int WidthPercentage
+ {
+ get { return widthPercentage; }
+ set { widthPercentage = value; }
+ }
+
+ public CustomGridColumn(PropertyDescriptor prop)
+ : base(prop)
+ {
+ }
+
+ object ICloneable.Clone()
+ {
+ return base.Clone();
+ }
+
+
+ }
+
+ [ListBindableAttribute(false)]
+ [Editor(typeof(GridBoundColumnsCollectionEditor), typeof(System.Drawing.Design.UITypeEditor))]
+ public class CustomGridColumnsCollection : GridBoundColumnsCollection, ICloneable
+ {
+ public CustomGridColumnsCollection(GridModelDataBinder table)
+ : base(table)
+ {
+ }
+
+ public override GridBoundColumn CreateBoundColumn(PropertyDescriptor pd)
+ {
+ return new CustomGridColumn(pd);
+ }
+
+
+ ///
+ /// Creates a new CustomGridColumnsCollection and creates copies of all members in this collection.
+ ///
+ /// A CustomGridColumnsCollection object.
+ public override object Clone()
+ {
+ GridModelDataBinder owner = null;
+ owner = this.Owner as GridModelDataBinder;
+ CustomGridColumnsCollection clone = new CustomGridColumnsCollection(owner);
+ foreach (GridBoundColumn item in this)
+ clone.Add((GridBoundColumn) item); //.Clone());
+ return clone;
+ }
+
+ ///
+ /// Gets a specified CustomGridColumn in the CustomGridColumnsCollection.
+ ///
+ ///
+ /// Gets a specified CustomGridColumn in the CustomGridColumnsCollection.
+ ///
+ public new CustomGridColumn this[int index]
+ {
+ get
+ {
+ return (CustomGridColumn) base[index];
+ }
+ }
+
+ ///
+ /// Gets a specified CustomGridColumn in the CustomGridColumnsCollection.
+ ///
+ public new CustomGridColumn this[string columnName]
+ {
+ get
+ {
+ return (CustomGridColumn) base[columnName];
+ }
+ }
+
+ ///
+ /// Gets a specified CustomGridColumn in the CustomGridColumnsCollection.
+ ///
+ public new CustomGridColumn this[PropertyDescriptor propDesc]
+ {
+ get
+ {
+ return (CustomGridColumn) base[propDesc];
+ }
+ }
+ }
+ public class SyncFusionBoundGrid : GridDataBoundGrid
+ {
+ ///
+ /// Default constructor.
+ ///
+ public SyncFusionBoundGrid() : base()
+ {
+ GridModelDataBinder.BoundColumnsCollectionType = typeof(CustomGridColumnsCollection);
+ }
+
+ ///
+ /// A collection of grid bound columns. This property is overridden so
+ /// that the type used to define a grid bound column is a specialized
+ /// version.
+ ///
+ [ Browsable(false), DesignerSerializationVisibilityAttribute( DesignerSerializationVisibility.Hidden ) ]
+ public override GridBoundColumnsCollection GridBoundColumns
+ {
+ get
+ {
+ return base.GridBoundColumns;
+ }
+ set
+ {
+
+ base.GridBoundColumns = value;
+ }
+ }
+
+ ///
+ /// A collection of grid bound columns. This property is overridden so
+ /// that the type used to define a grid bound column is a specialized
+ /// version.
+ ///
+ [ DesignerSerializationVisibilityAttribute( DesignerSerializationVisibility.Content ) ]
+ [ LocalizableAttribute(true) ]
+ [ Description( "Manages the columns to be displayed in the GridDataBoundGrid." ) ]
+ [ Category( "Data" ) ]
+ [ RefreshProperties( RefreshProperties.All ) ]
+ [ Editor( typeof(GridBoundColumnsCollectionEditor), typeof(UITypeEditor) ) ]
+ public CustomGridColumnsCollection CustomGridColumns
+ {
+ get
+ {
+ return base.GridBoundColumns as CustomGridColumnsCollection;
+ }
+ set
+ {
+
+ base.GridBoundColumns = value;
+ }
+ }
+ }
+ // Sets the style theme for scroll bars. Make sure the property �ThemesEnabled = true;�
+ this.gridDataBoundGrid1.GridOfficeScrollBars = OfficeScrollBars.Metro;
+
+
+ ' Sets the style theme for scroll bars. Make sure the property �ThemesEnabled = true;�
+ e.gridDataBoundGrid1.GridOfficeScrollBars = OfficeScrollBars.Metro
+
+
+ // Enables the Office2007 scroll bars.
+ this.gridDataBoundGrid1.Office2007ScrollBars = true;
+ // Sets the color schemes for the Office2007 scroll bars.
+ this.gridDataBoundGrid1.Office2007ScrollBarsColorScheme = Office2007ColorScheme.Black;
+
+
+ ' Enables the Office2007 scroll bars.
+ Me.gridDataBoundGrid1.Office2007ScrollBars = True
+ ' Sets the color schemes for the Office2007 scroll bars.
+ Me.gridDataBoundGrid1.Office2007ScrollBarsColorScheme = Office2007ColorScheme.Black
+
+
+ GridFindReplaceDialogSink findReplaceDialogSink;
+
+ public GridFindReplaceDialogSink GridFindReplaceDialogSink
+ {
+ get
+ {
+ if (findReplaceDialogSink == null)
+ {
+ findReplaceDialogSink = new GridFindReplaceDialogSink(this);
+ }
+ return findReplaceDialogSink;
+ }
+ }
+
+ protected override void OnCurrentCellActivated(EventArgs e)
+ {
+ GridFindReplaceDialog.ResetFindLocation();
+ base.OnCurrentCellActivated(e);
+ }
+
+ protected override void OnControlGotFocus()
+ {
+ GridFindReplaceDialog.SetActiveSinkIfVisible(GridFindReplaceDialogSink);
+ base.OnControlGotFocus();
+ }
+
+ // to show the dialog:
+ GridFindReplaceDialog frDialog = GridFindReplaceDialog.Instance;
+ frDialog.SetState(grid.GridFindReplaceDialogSink, "", false);
+ frDialog.Show();
+
+
+ Dim findReplaceDialogSink As GridFindReplaceDialogSink
+
+
+ Public ReadOnly Property GridFindReplaceDialogSink() As GridFindReplaceDialogSink
+ Get
+ If findReplaceDialogSink Is Nothing Then
+ findReplaceDialogSink = New GridFindReplaceDialogSink(Me)
+ End If
+ Return findReplaceDialogSink
+ End Get
+ End Property
+
+
+ Protected Overrides Sub OnCurrentCellActivated(e As EventArgs)
+ GridFindReplaceDialog.ResetFindLocation()
+ MyBase.OnCurrentCellActivated(e)
+ End Sub 'OnCurrentCellActivated
+
+
+ Protected Overrides Sub OnControlGotFocus()
+ GridFindReplaceDialog.SetActiveSinkIfVisible(GridFindReplaceDialogSink)
+ MyBase.OnControlGotFocus()
+ End Sub 'OnEnter
+
+ ' to show the dialog:
+ Dim frDialog As GridFindReplaceDialog = GridFindReplaceDialog.Instance
+ frDialog.SetState(grid.GridFindReplaceDialogSink, "", False)
+ frDialog.Show()
+
+
+ //suspend calculations...
+ GridFormulaCellModel formulaModel = this.gridControl1.CellModels["FormulaCell"] as GridFormulaCellModel;
+ formulaModel.CalculatingSuspended = true;
+
+ ....
+ //make changes, say to, cells in the GridRangeInfo.Cells(1,1,10,20).
+ ....
+
+ //later resume calculations and refresh any cells that depend on GridRangeInfo.Cells(1,1,10,20)
+ GridFormulaCellModel formulaModel = this.gridControl1.CellModels["FormulaCell"] as GridFormulaCellModel;
+ formulaModel.CalculatingSuspended = false;
+ formulaModel.RefreshRange(GridRangeInfo.Cells(1,1,10,20));
+
+
+
+ 'suspend calculations...
+ Dim formulaModel As GridFormulaCellModel = Me.gridControl1.CellModel("FormulaCell")
+ formulaModel.CalculatingSuspended = True
+
+ ....
+ 'make changes, say to, cells in the GridRangeInfo.Cells(1,1,10,20).
+ ....
+
+ 'later resume calculations and refresh any cells that depend on GridRangeInfo.Cells(1,1,10,20)
+ Dim formulaModel As GridFormulaCellModel = Me.gridControl1.CellModel("FormulaCell")
+ formulaModel.CalculatingSuspended = False
+ formulaModel.RefreshRange(GridRangeInfo.Cells(1, 1, 10, 2))
+
+
+
+ public void DisplayAllAffectedCells()
+ {
+ GridFormulaEngine engine = ((GridFormulaCellModel)this.gridControl1.CellModels["FormulaCell"]).Engine;
+
+ foreach(object o in engine.DependentCells.Keys)
+ {
+ string s1 = o as string;
+ Console.Write(s1 + " affects ");
+ Hashtable ht = (Hashtable) engine.DependentCells[s1];
+ foreach(object o1 in ht.Keys)
+ {
+ string s2 = o1 as string;
+ Console.Write(s2 + " ");
+ }
+ Console.WriteLine(string.Empty);
+ }
+ }
+
+
+ Public Sub DisplayAllAffectedCells()
+ Dim engine As GridFormulaEngine = CType(Me.gridControl1.CellModels("FormulaCell"), GridFormulaCellModel).Engine
+ Dim o As Object
+ For Each o In engine.DependentCells.Keys
+ Dim s1 As String = CStr(o)
+ Console.Write((s1 + " affects "))
+ Dim ht As Hashtable = CType(engine.DependentCells(s1), Hashtable)
+ Dim o1 As Object
+ For Each o1 In ht.Keys
+ Dim s2 As String = CStr(o1)
+ Console.Write((s2 + " "))
+ Next o1
+ Console.WriteLine(string.Empty)
+ Next o
+ End Sub 'DisplayAllAffectedCells
+
+
+ public void DisplayAllFormulaDependencies()
+ {
+ GridFormulaEngine engine = ((GridFormulaCellModel)this.gridControl1.CellModels["FormulaCell"]).Engine;
+
+ foreach(object o in engine.DependentFormulaCells.Keys)
+ {
+ string s1 = o as string;
+ Console.Write(s1 + " depends upon ");
+ Hashtable ht = (Hashtable) engine.DependentFormulaCells[s1];
+ foreach(object o1 in ht.Keys)
+ {
+ string s2 = o1 as string;
+ Console.Write(s2 + " ");
+ }
+ Console.WriteLine(string.Empty);
+ }
+ }
+
+
+ Public Sub DisplayAllFormulaDependencies()
+ Dim engine As GridFormulaEngine = CType(Me.gridControl1.CellModels("FormulaCell"), GridFormulaCellModel).Engine
+
+ Dim o As Object
+ For Each o In engine.DependentFormulaCells.Keys
+ Dim s1 As String = CStr(o)
+ Console.Write((s1 + " depends upon "))
+ Dim ht As Hashtable = CType(engine.DependentFormulaCells(s1), Hashtable)
+ Dim o1 As Object
+ For Each o1 In ht.Keys
+ Dim s2 As String = CStr(o1)
+ Console.Write((s2 + " "))
+ Next o1
+ Console.WriteLine(string.Empty)
+ Next o
+ End Sub 'DisplayAllFormulaDependencies
+
+
+ // Sets the Copy, paste options of the formula cell in the grid.
+ GridFormulaEngine calculateEngine = new GridFormulaEngine(this.gridControl1.Model);
+ calculateEngine.FormulaCopyFlags = GridFormulaCopyFlags.ClipBoardFormula;
+ calculateEngine.FormulaCopyFlags = GridFormulaCopyFlags.NamedRangeReferencesUpdated;
+
+
+ ' Sets the Copy, paste options of the formula cell in the grid.
+ Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
+ calculateEngine.FormulaCopyFlags = GridFormulaCopyFlags.ClipBoardFormula
+ calculateEngine.FormulaCopyFlags = GridFormulaCopyFlags.NamedRangeReferencesUpdated
+
+
+ //Register 3 grids so cell can be referenced across grids.
+ int sheetfamilyID = GridFormulaEngine.CreateSheetFamilyID();
+ GridFormulaEngine.RegisterGridAsSheet("summary", this.gridControl1.Model, sheetfamilyID);
+ GridFormulaEngine.RegisterGridAsSheet("income", this.gridControl2.Model, sheetfamilyID);
+ GridFormulaEngine.RegisterGridAsSheet("expenses", this.gridControl3.Model, sheetfamilyID);
+ ....
+ //Sample formula usage for cells in gridControl1, the 'summary' grid.
+ //This code sums up some cells from gridControl3, the 'expenses' grid,
+ //and gridControl2, the 'income' grid.
+
+ //Sum the range B2:B8 from the expenses grid.
+ this.gridControl1[3,4].Text = "= Sum(expenses!B2:expenses!B8)";
+
+ //Sum the range B2:B4 from the income grid.
+ this.gridControl1[4,4].Text = "= Sum(income!B2:income!B4)";
+
+
+
+ 'Register 3 grids so cells can be referenced across grids.
+ Dim sheetfamilyID As Integer = GridFormulaEngine.CreateSheetFamilyID();
+ GridFormulaEngine.RegisterGridAsSheet("summary", Me.gridControl1.Model, sheetfamilyID)
+ GridFormulaEngine.RegisterGridAsSheet("income", Me.gridControl2.Model, sheetfamilyID)
+ GridFormulaEngine.RegisterGridAsSheet("expenses", Me.gridControl3.Model, sheetfamilyID)
+ ....
+ 'Sample formula usage for cells in gridControl1, the 'summary' grid.
+ 'This code sums ups some cells from gridControl3, the 'expenses' grid,
+ 'and gridControl2, the 'income' grid.
+
+ 'Sum the range B2:B8 from the expenses grid.
+ Me.gridControl1(3,4).Text = "= Sum(expenses!B2:expenses!B8)"
+
+ 'Sum the range B2:B4 from the income grid.
+ Me.gridControl1(4,4).Text = "= Sum(income!B2:income!B4)"
+
+
+ //column 4 is formula col which used relative notation (row = 0)
+ //to enter the formulas as a simple string as the default value
+ //in the column
+ this.gridControl1.ColWidths[4] = 100;
+ this.gridControl1[0, 4].Text = "FormulaCell";
+ this.gridControl1.ColStyles[4].CellType = "FormulaCell";
+ this.gridControl1.ColStyles[4].Text = "= A0 + C0";
+
+
+ public string[] FormulaErrorStrings = new string[]
+ {
+ "binary operators cannot start an expression", //0
+ "cannot parse", //1
+ "bad library", //2
+ "invalid char in front of", //3
+ "number contains 2 decimal points", //4
+ "expression cannot end with an operator", //5
+ "invalid characters following an operator", //6
+ "invalid character in number", //7
+ "mismatched parentheses", //8
+ "unknown formula name", //9
+ "requires a single argument", //10
+ "requires 3 arguments", //11
+ "invalid Math argument", //12
+ "requires 2 arguments", //13
+ "bad index", //14
+ "too complex", //15
+ "circular reference: ", //16
+ "missing formula", //17
+ "improper formula", //18
+ "invalid expression", //19
+ "cell empty" //20
+ "bad formula", //21
+ "empty expression", //22
+ "Virtual Mode required - set UsesVirtualDataSource", //23
+ "mismatched string quotes", //24
+ "wrong number of arguments", //25
+ "invalid arguments", //26
+ "iterations do not converge", //27
+ "Control named '{0}' is already registered", //28
+ "Calculation overflow", //29
+ "missing operand" //30
+ "unknown sheet" //30
+ };
+
+
+ GridFormulaEngine calculateEngine = new GridFormulaEngine(this.gridControl1.Model);
+ // Parses the given string.
+ string parsedFormula = calculateEngine.Parse("=(29-7)+56");
+ Console.WriteLine("The parsed formula string is " + parsedFormula);
+
+
+ Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
+ ' Parses the given string.
+ Dim parsedFormula As String = calculateEngine.Parse("=(29-7)+56")
+
+
+
+ // Adds the NamedRange to the NamedRange list.
+ GridFormulaEngine calculateEngine = new GridFormulaEngine(this.gridControl1.Model);
+ calculateEngine.NamedRanges.Add("A", 50);
+ calculateEngine.NamedRanges.Add("B", 25);
+
+
+ ' Adds the NamedRange to the NamedRange list.
+ Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
+ calculateEngine.NamedRanges.Add("A", 50)
+ calculateEngine.NamedRanges.Add("B", 25)
+
+
+ // Removes the named range from the collection.
+ GridFormulaEngine calculateEngine = new GridFormulaEngine(this.gridControl1.Model);
+ calculateEngine.RemoveNamedRange("A");
+
+
+ ' Removes the named range from the collection.
+ Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
+ calculateEngine.RemoveNamedRange("A")
+
+
+ public delegate string LibraryFunction(string args);
+
+
+ GridFormulaCellModel myModel = this.gridControl1.CellModels["FormulaCell"] as GridFormulaCellModel;
+ GridFormulaEngine calculateEngine = new GridFormulaEngine(this.gridControl1.Model);
+ // Add the custom-function to the library functions.
+ myModel.Engine.AddFunction("GetMaxNum", new GridFormulaEngine.LibraryFunction(myMaxNum));
+ // Custom function to be added to the library.
+ public string myMaxNum(string Args)
+ {
+ GridFormulaCellModel myModel = this.gridControl1.CellModels["FormulaCell"] as GridFormulaCellModel;
+ GridFormulaEngine engine = myModel.Engine;
+ // Perform the required operations.
+ int a, b, c;
+ string[] coll = Args.Split(new char[] { ',' });
+ a = Convert.ToInt32(coll[0]);
+ b = Convert.ToInt32(coll[1]);
+ c = Convert.ToInt32(coll[2]);
+ int big = (a > b ? a : b);
+ int bigger = (big > c ? big : c);
+ // Make sure to define the custom function with string return type.
+ return bigger.ToString();
+ }
+
+
+ Dim myModel As GridFormulaCellModel = TryCast(Me.gridControl1.CellModels("FormulaCell"), GridFormulaCellModel)
+ Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
+ ' Add the custom-function to the library functions.
+ myModel.Engine.AddFunction("GetMaxNum", New GridFormulaEngine.LibraryFunction(myMaxNum))
+ ' Custom function to be added to the library.
+ Public Function myMaxNum(ByVal Args As String) As String
+ Dim myModel As GridFormulaCellModel = TryCast(Me.gridControl1.CellModels("FormulaCell"), GridFormulaCellModel)
+ Dim engine As GridFormulaEngine = myModel.Engine
+ ' Perform the required operations.
+ Dim a, b, c As Integer
+ Dim coll() As String = Args.Split(New Char() { ","c })
+ a = Convert.ToInt32(coll(0))
+ b = Convert.ToInt32(coll(1))
+ c = Convert.ToInt32(coll(2))
+ Dim big As Integer = (If(a > b, a, b))
+ Dim bigger As Integer = (If(big > c, big, c))
+ ' Make sure to define the custom function with string return type.
+ Return bigger.ToString()
+ End Function
+
+
+ // Removes the function from the library.
+ GridFormulaEngine calculateEngine = new GridFormulaEngine(this.gridControl1.Model);
+ calculateEngine.RemoveFunction("Sum");
+
+
+ ' Removes the function from the library.
+ Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
+ calculateEngine.RemoveFunction("Sum")
+
+
+ GridFormulaEngine calculateEngine = new GridFormulaEngine(this.gridControl1.Model);
+ string myFormula = "(7+6)*2";
+ // Parses the given string.
+ string parsedValue = calculateEngine.Parse(myFormula);
+ // Computes the resultant value.
+ string computedValue = calculateEngine.ComputeFormulaText(parsedValue);
+ Console.WriteLine("The computed value is " + computedValue);
+
+
+ Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
+ Dim myFormula As String = "(7+6)*2"
+ ' Parses the given string
+ Dim parsedValue As String = calculateEngine.Parse(myFormula)
+ ' Computes the resultant value.
+ Dim computedValue As String = calculateEngine.ComputeFormulaText(parsedValue)
+
+
+
+ GridFormulaEngine calculateEngine = new GridFormulaEngine(this.gridControl1.Model);
+ double[] arr = { 4, 7, 9, 14, 23, 56 }; double q = 1;
+ // Computes the mean value of given numbers.
+ this.gridControl1[5, 5].CellValue = calculateEngine.Mean(arr);
+ Console.WriteLine("The mean of array values are " + this.gridControl1[5, 5].CellValue);
+
+
+ Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
+ Dim arr() As Double = { 4, 7, 9, 14, 23, 56 }
+ Dim q As Double = 1
+ ' Computes the mean value of given numbers.
+ Me.gridControl1(5, 5).CellValue = calculateEngine.Mean(arr)
+
+
+
+ Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
+ Dim arr() As Double = { 4, 7, 9, 14, 23, 56 }
+ ' Computes the mean value of given numbers.
+ Me.gridControl1(5, 5).CellValue = calculateEngine.Mean(arr,1,2)
+
+
+
+ void gridControl1_CellClick(object sender, GridCellClickEventArgs e)
+ {
+ // Gets the cell value from the given row index and column index.
+ GridFormulaEngine calculateEngine = new GridFormulaEngine(this.gridControl1.Model);
+ string cellValue = calculateEngine.GetValueFromGrid(e.RowIndex, e.ColIndex);
+ Console.WriteLine("The Cell value is " + cellValue);
+ }
+
+
+ Private Sub gridControl1_CellClick(ByVal sender As Object, ByVal e As GridCellClickEventArgs)
+ ' Gets the cell value from the given row index and column index.
+ Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
+ Dim cellValue As String = calculateEngine.GetValueFromGrid(e.RowIndex, e.ColIndex)
+
+ End Sub
+
+
+ // Gets the cell value from a particular cell index.
+ GridFormulaEngine calculateEngine = new GridFormulaEngine(this.gridControl1.Model);
+ string cellValue = calculateEngine.GetValueFromGrid("C33");
+ Console.WriteLine("The cell value is " + cellValue);
+
+
+ ' Gets the cell value from a particular cell index.
+ Dim calculateEngine As New GridFormulaEngine(Me.gridControl1.Model)
+ Dim cellValue As String = calculateEngine.GetValueFromGrid("C33")
+
+
+
+ public string ComputeSumPosNums(string args)
+ {
+ GridFormulaEngine engine = GridFormulaEngine.FunctionEngineContext;
+ string sum = string.Empty;
+ foreach(string r in args.Split(new char[]{','}))
+ {
+ if(r.IndexOf(':') > -1) //is a cellrange
+ {
+ foreach(string s in engine.GetCellsFromArgs(r))
+ {
+ s1 = engine.GetValueFromArg(s).Replace("'",string.Empty);
+ //... do some calculations to compute sum
+ }
+ }
+ }
+ return sum.ToString();
+ }
+
+
+ Public Function ComputeSumPosNums(args As String) As String
+ Dim engine As GridFormulaEngine = GridFormulaEngine.FunctionEngineContext
+ Dim sum As String = string.Empty
+ Dim r As String
+ For Each r In args.Split(New Char() {","c})
+ If r.IndexOf(":"c) > - 1 Then 'is a cellrange
+ Dim s As String
+ For Each s In engine.GetCellsFromArgs(r)
+ s1 = engine.GetValueFromArg(s).Replace("'", string.Empty)
+ '... do some calculations to compute sum
+ Next s
+ End If
+ Next r
+ Return sum.ToString()
+ End Function 'ComputeSumPosNums
+
+
+ //subscribe to the event before any formulas are loaded into the grid...
+ this.engine = ((GridFormulaCellModel)gridControl1.CellModels["FormulaCell"]).Engine;
+ this.engine.FormulaParsing += new GridFormulaParsingEventHandler(engine_FormulaParsing);
+
+ //Here is the handler code that adds an = if necessary so any string beginning with +, - or =
+ //is treated as a formula.
+ void engine_FormulaParsing(object sender, GridFormulaParsingEventArgs e)
+ {
+ //allow cells starting with + and - to be treated as formula cells.
+ if (e.Text.StartsWith("-"))
+ e.Text = "=" + e.Text;
+ else if (e.Text.StartsWith("+"))
+ e.Text = "=" + e.Text.Substring(1);
+ }
+
+
+
+
+
+
+ // Initializes the image list to be displayed in the grid.
+ ImageList img = new ImageList();
+ // Adds the image to the list.
+ img.Images.Add(new Bitmap(FindImageFile(@"\...\...\...\FileName.jpg")));
+ // Assigns the image-list to the grid.
+ this.gridListControl1.ImageList = img;
+
+
+ ' Initializes the image list to be displayed in the grid.
+ Dim img As New ImageList()
+ ' Adds the image to the list.
+ img.Images.Add(New Bitmap(FindImageFile("\...\...\...\FileName.jpg")))
+ ' Assigns the image-list to the grid.
+ Me.gridListControl1.ImageList = img
+
+
+ void Grid_CellClick(object sender, GridCellClickEventArgs e)
+ {
+ // Gets the style properties of a given column index and assigns to other GridStyleInfo instance.
+ GridStyleInfo myStyle = this.gridListControl1.GetColumnStyle(e.ColIndex);
+ }
+
+
+ Private Sub Grid_CellClick(ByVal sender As Object, ByVal e As GridCellClickEventArgs)
+ ' Gets the style properties of a given column index and assigns to other GridStyleInfo instance.
+ Dim myStyle As GridStyleInfo = Me.gridListControl1.GetColumnStyle(e.ColIndex)
+ End Sub
+
+
+ // Creates a new column in the grid.
+ PropertyDescriptor propertyDesc = this.gridListControl1.GetColumnStyle(2).Tag as PropertyDescriptor;
+ this.gridListControl1.CreateGridColumn(propertyDesc, 4);
+
+
+ ' Creates a new column in the grid.
+ Dim propertyDesc As PropertyDescriptor = TryCast(Me.gridListControl1.GetColumnStyle(2).Tag, PropertyDescriptor)
+ Me.gridListControl1.CreateGridColumn(propertyDesc, 4)
+
+
+ // Finds the specified string in the grid and returns it's index value.
+ // If the string case should be ignored, then the last parameter should be "true"
+ int foundedItem=this.gridListControl1.FindItem("o", true, 1, true);
+ Console.WriteLine("The item is found in the index " + foundedItem);
+
+
+ ' Finds the specified string in the grid and returns it's index value.
+ ' If the string case should be ignored, then the last parameter should be "true"
+ Dim foundedItem As Integer=Me.gridListControl1.FindItem("o", True, 1, True)
+
+
+
+ // Sets the border style of the grid.
+ this.gridListControl1.BorderStyle = BorderStyle.FixedSingle;
+
+
+ ' Sets the border style of the grid.
+ Me.gridListControl1.BorderStyle = BorderStyle.FixedSingle
+
+
+ // Clears the selection done in the grid.
+ this.gridListControl1.ClearSelected();
+
+
+ ' Clears the selection done in the grid.
+ Me.gridListControl1.ClearSelected()
+
+
+ // Finds the specified string in the grid and returns it's index value.
+ // The string is considered as case-insensitive.
+ int foundedItem = this.gridListControl1.FindString("Texas");
+ Console.WriteLine("The specified string is found in the index " + foundedItem);
+
+
+ ' Finds the specified string in the grid and returns it's index value.
+ ' The string is considered as case-insensitive.
+ Dim foundedItem As Integer = Me.gridListControl1.FindString("Texas")
+
+
+
+ // Finds the specified string in the grid from a specific index to start the search and returns it's index value.
+ // The string is considered as case-insensitive.
+ int foundedItem = this.gridListControl1.FindString("Texas", 5);
+ Console.WriteLine("The specified string is found in the index " + foundedItem);
+
+
+ ' Finds the specified string in the grid from a specific index to start the search and returns it's index value.
+ ' The string is considered as case-insensitive.
+ Dim foundedItem As Integer = Me.gridListControl1.FindString("Texas", 5)
+
+
+
+ void Grid_CellClick(object sender, GridCellClickEventArgs e)
+ {
+ int rowHeight = this.gridListControl1.GetItemHeight(e.RowIndex);
+ Console.WriteLine("The row height is " + rowHeight);
+ }
+
+
+ Private Sub Grid_CellClick(ByVal sender As Object, ByVal e As GridCellClickEventArgs)
+ Dim rowHeight As Integer = Me.gridListControl1.GetItemHeight(e.RowIndex)
+
+ End Sub
+
+
+ // Sets the specified column to display images in the grid. Here "2" is the Column index.
+ this.gridListControl1.ImageColumn = 2;
+
+
+ ' Sets the specified column to display images in the grid. Here "2" is the Column index.
+ Me.gridListControl1.ImageColumn = 2
+
+
+ // Sets the data source to the grid.
+ DataTable dataTable = new DataTable();
+ this.gridListControl1.DataSource = dataTable;
+ // Gets the row count of the associated data source to the grid.
+ int rowcount = this.gridListControl1.GetRowCount(dataTable);
+ Console.WriteLine("Row count of the associated data source is " + rowcount);
+
+
+ ' Sets the data source to the grid.
+ Dim dataTable As New DataTable()
+ Me.gridListControl1.DataSource = dataTable
+ ' Gets the row count of the associated data source to the grid.
+ Dim rowcount As Integer = Me.gridListControl1.GetRowCount(dataTable)
+
+
+
+ // Sets the selection mode to the grid.
+ this.gridListControl1.SelectionMode = SelectionMode.MultiExtended;
+
+
+ ' Sets the selection mode to the grid.
+ Me.gridListControl1.SelectionMode = SelectionMode.MultiExtended
+
+
+ // Sets the specific index of the grid to be in the selected state.
+ this.gridListControl1.SetSelected(5, true);
+
+
+ ' Sets the specific index of the grid to be in the selected state.
+ Me.gridListControl1.SetSelected(5, True)
+
+
+ // Sets the row height of the grid.
+ this.gridListControl1.ItemHeight = 30;
+
+
+ ' Sets the row height of the grid.
+ Me.gridListControl1.ItemHeight = 30
+
+
+ // Apply the visual styles to the grid.
+ // Make sure to set the "ThemesEnabled = true;
+ this.gridListControl1.GridVisualStyles = GridVisualStyles.Metro;
+
+
+ ' Apply the visual styles to the grid.
+ ' Make sure to set the "ThemesEnabled = true;
+ Me.gridListControl1.GridVisualStyles = GridVisualStyles.Metro
+
+
+ // Sets the color styles of the grid. This property doesn't depends on "ThemesEnabled" property.
+ this.gridListControl1.ColorStyles = ColorStyles.Office2010Silver;
+
+
+ ' Sets the color styles of the grid. This property doesn't depends on "ThemesEnabled" property.
+ Me.gridListControl1.ColorStyles = ColorStyles.Office2010Silver
+
+
+ // Sets the back-color for headers.
+ this.gridListControl1.HeaderBackColor = Color.Red;
+
+
+ ' Sets the back-color for headers.
+ Me.gridListControl1.HeaderBackColor = Color.Red
+
+
+ // Sets the text color of the grid.
+ this.gridListControl1.HeaderTextColor = Color.White;
+
+
+ ' Sets the text color of the grid.
+ Me.gridListControl1.HeaderTextColor = Color.White
+
+
+ // Sets the alpha blend selection color
+ this.gridListControl1.AlphaBlendSelectionColor = Color.Red;
+
+
+ ' Sets the alpha blend selection color
+ Me.gridListControl1.AlphaBlendSelectionColor = Color.Red
+
+
+ public class GroupDropAreaDragHeaderMouseController : GroupDragHeaderMouseControllerBase
+ {
+ public GroupDropAreaDragHeaderMouseController(GridGroupDropArea grid)
+ {
+ this.groupDropArea = grid;
+ isGroupAreaOrigin = true;
+ clickCellsController = new GridClickCellsMouseController(grid);
+ }
+
+ internal GridClickCellsMouseController clickCellsController;
+ int clickCellsControllerHitTest = 0;
+
+ public GridClickCellsMouseController ClickCellsController
+ {
+ get
+ {
+ return clickCellsController;
+ }
+ }
+
+ public void ResetClickCellsController()
+ {
+ if (this.entered)
+ clickCellsController.MouseHoverLeave(EventArgs.Empty);
+ else if (clickCellsControllerHitTest != 0)
+ clickCellsController.CancelMode();
+ entered = false;
+ clickCellsControllerHitTest = 0;
+ }
+
+ // unrelated code left out here ...
+
+ #region IMouseController implementation
+
+ public virtual string Name
+ {
+ get
+ {
+ return "DragGroupHeader";
+ }
+ }
+
+ public virtual Cursor Cursor
+ {
+ get
+ {
+ if (cursor != null)
+ return cursor;
+ return clickCellsController.Cursor;
+ }
+ }
+
+ bool entered = false;
+
+ public virtual void MouseHoverEnter()
+ {
+ if (clickCellsControllerHitTest != 0)
+ {
+ entered = true;
+ clickCellsController.MouseHoverEnter();
+ }
+ }
+
+ public virtual void MouseHover(MouseEventArgs e)
+ {
+ if (clickCellsControllerHitTest != 0)
+ clickCellsController.MouseHover(e);
+ }
+
+ public virtual void MouseHoverLeave(EventArgs e)
+ {
+ if (entered)
+ {
+ clickCellsController.MouseHoverLeave(e);
+ entered = false;
+ }
+ }
+
+ public virtual void MouseDown(MouseEventArgs e)
+ {
+ if (clickCellsControllerHitTest != 0)
+ clickCellsController.MouseDown(e);
+ }
+
+ public virtual void MouseMove(MouseEventArgs e)
+ {
+ if (clickCellsControllerHitTest != 0)
+ clickCellsController.MouseMove(e);
+ }
+
+ public virtual void MouseUp(MouseEventArgs e)
+ {
+ if (clickCellsControllerHitTest != 0)
+ clickCellsController.MouseUp(e);
+ }
+
+ public virtual void CancelMode()
+ {
+ if (clickCellsControllerHitTest != 0)
+ clickCellsController.CancelMode();
+ }
+
+ public virtual int HitTest(MouseEventArgs e, IMouseController controller)
+ {
+ clickCellsControllerHitTest = clickCellsController.HitTest(e, controller);
+ return clickCellsControllerHitTest;
+ }
+
+ #endregion
+ }
+
+
+ GridPrintDocument pd = new GridPrintDocument(grid); //Assumes the default printer
+ if (PrinterSettings.storedPageSettings != null)
+ {
+ pd.DefaultPageSettings = PrinterSettings.storedPageSettings ;
+ }
+ PrintDialog dlg = new PrintDialog() ;
+ dlg.Document = pd;
+ dlg.AllowSelection = true;
+ dlg.AllowSomePages = true;
+ DialogResult result = dlg.ShowDialog();
+
+ if (result == DialogResult.OK)
+ {
+ pd.Print();
+ }
+
+ Use the following code for print preview:
+
+ GridControlBase grid = ActiveGrid;
+ GridPrintDocument pd = new GridPrintDocument(grid, true); //Assumes the default printer
+ if (PrinterSettings.storedPageSettings != null)
+ {
+ pd.DefaultPageSettings = PrinterSettings.storedPageSettings ;
+ }
+
+ PrintPreviewDialog dlg = new PrintPreviewDialog() ;
+ dlg.Document = pd;
+ dlg.ShowDialog();
+
+
+ // Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
+ ExpressionFieldEvaluator expression = new ExpressionFieldEvaluator(this.gridControl1.Model);
+ int call = expression.MaximumRecursiveCalls = 5;
+ Console.WriteLine("The maximum recursive calls allowed is " + call);
+
+
+ ' Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
+ Dim expression As New ExpressionFieldEvaluator(Me.gridControl1.Model)
+ Dim[call] As Integer = expression.MaximumRecursiveCalls = 5
+
+
+
+ public string[] FormulaErrorStrings = new string[]
+ {
+ "binary operators cannot start an expression", //0
+ "cannot parse", //1
+ "bad library", //2
+ "invalid char in front of", //3
+ "number contains 2 decimal points", //4
+ "expression cannot end with an operator", //5
+ "invalid characters following an operator", //6
+ "invalid character in number", //7
+ "mismatched parentheses", //8
+ "unknown formula name", //9
+ "requires a single argument", //10
+ "requires 3 arguments", //11
+ "invalid Math argument", //12
+ "requires 2 arguments", //13
+ "bad index", //14
+ "too complex", //15
+ "circular reference: ", //16
+ "missing formula", //17
+ "improper formula", //18
+ "invalid expression", //19
+ "cell empty", //20
+ "empty expression", //21
+ "mismatched string tics", //22
+ "named functions not supported in expressions", //23
+ "not a formula", //24
+ "missing operand" //25
+ };
+
+
+ void gridControl1_CellClick(object sender, GridCellClickEventArgs e)
+ {
+ // Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
+ ExpressionFieldEvaluator expression = new ExpressionFieldEvaluator(this.gridControl1.Model);
+ // The expression to be parsed.
+ string expressionName = "=((8+6)*(2))";
+ // The parsed value of the expression.
+ string parsedValue = expression.Parse(expressionName);
+ // The resultant value.
+ string computedValue = expression.ComputeFormulaValueAt(parsedValue, e.RowIndex, e.ColIndex, expressionName);
+ Console.WriteLine("The parsed string from the given string is " + computedValue);
+ }
+
+
+ Private Sub gridControl1_CellClick(ByVal sender As Object, ByVal e As GridCellClickEventArgs)
+ ' Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
+ Dim expression As New ExpressionFieldEvaluator(Me.gridControl1.Model)
+ ' The expression to be parsed.
+ Dim expressionName As String = "=((8+6)*(2))"
+ ' The parsed value of the expression.
+ Dim parsedValue As String = expression.Parse(expressionName)
+ ' The resultant value.
+ Dim computedValue As String = expression.ComputeFormulaValueAt(parsedValue, e.RowIndex, e.ColIndex, expressionName)
+
+ End Sub
+
+
+ // Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
+ ExpressionFieldEvaluator expression = new ExpressionFieldEvaluator(this.gridControl1.Model);
+ Parses the given valid string.
+ string parsedString = expression.Parse("=((8+6)*(2))");
+ Console.WriteLine("The parsed string from the given string is " + parsedString);
+ // Computes the parsed given string into the required result.
+ parsedString = expression.ComputeFormulaValueAt(parsedString);
+ Console.WriteLine("The parsed string from the given string is " + parsedString);
+
+
+ ' Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
+ Dim expression As New ExpressionFieldEvaluator(Me.gridControl1.Model)
+ ' Parses the given valid string.
+ Dim parsedString As String = expression.Parse("=((8+6)*(2))")
+
+ ' Computes the parsed given string into the required result.
+ parsedString = expression.ComputeFormulaValueAt(parsedString)
+
+
+
+ void gridControl1_CellClick(object sender, GridCellClickEventArgs e)
+ {
+ // Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
+ ExpressionFieldEvaluator expression = new ExpressionFieldEvaluator(this.gridControl1.Model);
+ this.gridControl1[e.RowIndex, e.ColIndex].CellValue = "=((8+6)*(2))";
+ // Parses the given string at the specified cell index.
+ string parsedFormula = expression.Parse(this.gridControl1[e.RowIndex, e.ColIndex].CellValue.ToString());
+ // Computes the parsed given string into the required result.
+ string parsedString = expression.ComputeFormulaValueAt(parsedFormula,e.RowIndex, e.ColIndex);
+ Console.WriteLine("The parsed string from the given string is " + parsedString);
+ }
+
+
+ Private Sub gridControl1_CellClick(ByVal sender As Object, ByVal e As GridCellClickEventArgs)
+ ' Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
+ Dim expression As New ExpressionFieldEvaluator(Me.gridControl1.Model)
+ Me.gridControl1(e.RowIndex, e.ColIndex).CellValue = "=((8+6)*(2))"
+ ' Parses the given string at the specified cell index.
+ Dim parsedFormula As String = expression.Parse(Me.gridControl1(e.RowIndex, e.ColIndex).CellValue.ToString())
+ ' Computes the parsed given string into the required result.
+ Dim parsedString As String = expression.ComputeFormulaValueAt(parsedFormula,e.RowIndex, e.ColIndex)
+
+ End Sub
+
+
+ // Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
+ ExpressionFieldEvaluator expression = new ExpressionFieldEvaluator(this.gridControl1.Model);
+ // Parses the given valid string.
+ string parsedString = expression.Parse("=((8+6)*(2))");
+ Console.WriteLine("The parsed string from the given string is " + parsedString);
+
+
+ ' Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
+ Dim expression As New ExpressionFieldEvaluator(Me.gridControl1.Model)
+ ' Parses the given valid string.
+ Dim parsedString As String = expression.Parse("=((8+6)*(2))")
+
+
+
+ // step 1 - register the function name and delegate
+ ExpressionFieldEvaluator evaluator = this.groupingEngine.TableDescriptor.ExpressionFieldEvaluator;//.CreateExpressionFieldEvaluator(this.groupingEngine.TableDescriptor);
+ evaluator.AddFunction("Func", new ExpressionFieldEvaluator.LibraryFunction(ComputeFunc));
+
+ //. . .
+
+ // step 1 - defining the method
+ // Computes the absolute value of arg1-2*arg2
+ // parameter s- a list of 2 arguments
+ // returns string holding computed value
+ public string ComputeFunc(string s)
+ {
+ //get the list delimiter (for en-us, its is a comma)
+ char comma = Convert.ToChar(this.gridGroupingControl1.Culture.TextInfo.ListSeparator);
+ string[] ss = s.Split(comma);
+ if(ss.GetLength(0) != 2)
+ throw new ArgumentException("Requires 2 arguments.");
+ double arg1, arg2;
+ if(double.TryParse(ss[0], System.Globalization.NumberStyles.Any, null, out arg1)
+ && double.TryParse(ss[1], System.Globalization.NumberStyles.Any, null, out arg2))
+ {
+ return Math.Abs(arg1 - 2 * arg2).ToString();
+ }
+ return "";
+ }
+
+
+ ' step 1 - register the function name and delegate
+ Dim evaluator As ExpressionFieldEvaluator = Me.groupingEngine.TableDescriptor.ExpressionFieldEvaluator
+ evaluator.AddFunction("Func", New ExpressionFieldEvaluator.LibraryFunction(AddressOf ComputeFunc))
+
+ '. . .
+
+ ' step 1 - defining the method
+ ' Computes the absolute value of arg1-2*arg2
+ ' parameter s- a list of 2 arguments
+ ' returns string holding computed value
+ Public Function ComputeFunc(s As String) As String
+ 'get the list delimiter (for en-us, its is a comma)
+ Dim comma As Char = Convert.ToChar(Me.gridGroupingControl1.Culture.TextInfo.ListSeparator)
+ Dim ss As String() = s.Split(comma)
+ If ss.GetLength(0) <> 2 Then
+ Throw New ArgumentException("Requires 2 arguments.")
+ End If
+ Dim arg1, arg2 As Double
+ If Double.TryParse(ss(0), System.Globalization.NumberStyles.Any, Nothing, arg1) _
+ AndAlso Double.TryParse(ss(1), System.Globalization.NumberStyles.Any, Nothing, arg2) Then
+ Return Math.Abs((arg1 - 2 * arg2)).ToString()
+ End If
+ Return ""
+ End Function 'ComputeFunc
+
+
+ // Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
+ ExpressionFieldEvaluator expression = new ExpressionFieldEvaluator(this.gridControl1.Model);
+ // Removes the function from the library.
+ expression.RemoveFunction("Add");
+
+
+ ' Creating the instances of the ExpressionFieldEvaluator and assigning the GridModel.
+ Dim expression As New ExpressionFieldEvaluator(Me.gridControl1.Model)
+ ' Removes the function from the library.
+ expression.RemoveFunction("Add")
+
+
+ protected override void OnDrawCellDisplayText(GridDrawCellDisplayTextEventArgs e)
+ {
+ base.OnDrawCellDisplayText (e);
+
+ GridGdiPaint.AllowTextOut = false;
+ if (!e.Cancel)
+ e.Cancel = GridGdiPaint.Instance.DrawText(e.Graphics, e.DisplayText, e.TextRectangle, e.Style);
+ }
+
+ protected override void OnFillRectangleHook(GridFillRectangleHookEventArgs e)
+ {
+ base.OnFillRectangleHook (e);
+
+ if (!e.Cancel)
+ e.Cancel = GridGdiPaint.Instance.FillRectangle(e.Graphics, e.Bounds, e.Brush);
+ }
+
+ - Or -
+
+ public class PerformanceGridControl : GridControl
+ {
+ private bool useGDI;
+
+ ///
+ /// Property UseGDI (bool)
+ ///
+ public bool UseGDI
+ {
+ get
+ {
+ return this.useGDI;
+ }
+ set
+ {
+ if (this.UseGDI != value)
+ {
+ this.useGDI = value;
+ Invalidate();
+ }
+ }
+ }
+
+ private bool useDoubleBuffer = true;
+
+ public bool UseDoubleBuffer
+ {
+ get
+ {
+ return this.useDoubleBuffer;
+ }
+ set
+ {
+ if (this.useDoubleBuffer != value)
+ {
+ this.useDoubleBuffer = value;
+ SetStyle(ControlStyles.Opaque, value);
+ SetStyle(ControlStyles.DoubleBuffer, value);
+ }
+ }
+ }
+
+ protected override void OnPaintBackground(PaintEventArgs pevent)
+ {
+ if (useDoubleBuffer)
+ base.OnPaintBackground (pevent);
+ }
+
+ protected override void OnDrawCellDisplayText(GridDrawCellDisplayTextEventArgs e)
+ {
+ base.OnDrawCellDisplayText (e);
+
+ if (!useGDI || e.Cancel)
+ return;
+
+ e.Cancel = GridGdiPaint.Instance.DrawText(e.Graphics, e.DisplayText, e.TextRectangle, e.Style);
+ }
+
+ protected override void OnFillRectangleHook(GridFillRectangleHookEventArgs e)
+ {
+ base.OnFillRectangleHook (e);
+
+ if (!useGDI || e.Cancel)
+ return;
+
+ e.Cancel = GridGdiPaint.Instance.FillRectangle(e.Graphics, e.Bounds, e.Brush);
+ }
+ }
+
+
+ protected override void OnDrawCellDisplayText(GridDrawCellDisplayTextEventArgs e)
+ {
+ base.OnDrawCellDisplayText (e);
+
+ GridGdiPaint.AllowTextOut = false;
+ if (!e.Cancel)
+ e.Cancel = GridGdiPaint.Instance.DrawText(e.Graphics, e.DisplayText, e.TextRectangle, e.Style, e.Bounds);
+ }
+
+ protected override void OnFillRectangleHook(GridFillRectangleHookEventArgs e)
+ {
+ base.OnFillRectangleHook (e);
+
+ if (!e.Cancel)
+ e.Cancel = GridGdiPaint.Instance.FillRectangle(e.Graphics, e.Bounds, e.Brush);
+ }
+
+
+ protected override void OnDrawCellDisplayText(GridDrawCellDisplayTextEventArgs e)
+ {
+ base.OnDrawCellDisplayText (e);
+
+ GridGdiPaint.AllowTextOut = false;
+ if (!e.Cancel)
+ {
+ GridControlBase grid = (GridControlBase) sender;
+ Rectangle clipBounds = grid.ViewLayout.RangeInfoToRectangle(GridRangeInfo.Cell(e.Style.CellIdentity.RowIndex, e.Style.CellIdentity.ColIndex), GridCellSizeKind.VisibleSize);
+ e.Cancel = GridGdiPaint.Instance.DrawText(e.Graphics, e.DisplayText, e.TextRectangle, e.Style, e.Bounds, clipBounds);
+ }
+ }
+
+ protected override void OnFillRectangleHook(GridFillRectangleHookEventArgs e)
+ {
+ base.OnFillRectangleHook (e);
+
+ if (!e.Cancel)
+ e.Cancel = GridGdiPaint.Instance.FillRectangle(e.Graphics, e.Bounds, e.Brush);
+ }
+
+
+ protected override void OnDrawCellDisplayText(GridDrawCellDisplayTextEventArgs e)
+ {
+ base.OnDrawCellDisplayText (e);
+
+ GridGdiPaint.AllowTextOut = false;
+ if (!e.Cancel)
+ {
+ GridControlBase grid = (GridControlBase) sender;
+ Rectangle clipBounds = grid.ViewLayout.RangeInfoToRectangle(GridRangeInfo.Cell(e.Style.CellIdentity.RowIndex, e.Style.CellIdentity.ColIndex), GridCellSizeKind.VisibleSize);
+ e.Cancel = GridGdiPaint.Instance.DrawText(e.Graphics, e.DisplayText, e.TextRectangle, e.Style, e.Bounds, clipBounds);
+ }
+ }
+
+ protected override void OnFillRectangleHook(GridFillRectangleHookEventArgs e)
+ {
+ base.OnFillRectangleHook (e);
+
+ if (!e.Cancel)
+ e.Cancel = GridGdiPaint.Instance.FillRectangle(e.Graphics, e.Bounds, e.Brush);
+ }
+
+
+ protected override void OnDrawCellDisplayText(GridDrawCellDisplayTextEventArgs e)
+ {
+ base.OnDrawCellDisplayText (e);
+
+ GridGdiPaint.AllowTextOut = false;
+ if (!e.Cancel)
+ e.Cancel = GridGdiPaint.Instance.DrawText(e.Graphics, e.DisplayText, e.TextRectangle, e.Style);
+ }
+
+ protected override void OnFillRectangleHook(GridFillRectangleHookEventArgs e)
+ {
+ base.OnFillRectangleHook (e);
+
+ if (!e.Cancel)
+ e.Cancel = GridGdiPaint.Instance.FillRectangle(e.Graphics, e.Bounds, e.Brush);
+ }
+
+
+ // 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);
+
+
+ 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.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;
+
+
+ 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));
+
+ 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
+ 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();
+
+
+ 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 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);
+ }
+ }
+
+ public override StyleInfoSubObjectIdentity CreateSubObjectIdentity(StyleInfoProperty sip)
+ {
+ return new ScrollerVisualStyleInfoSubObjectIdentity(this, sip);
+ }
+
+
+ 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);
+
+
+ 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();
+ }
+ }
+
+ 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
+
+
+ // 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");
+
+
+ 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). +
+ // 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();
+ }
+
+
+ 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"
+
+
+ public static GridModel LoadSoap(Stream s)
+ {
+ try
+ {
+ AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(SharedWindowsAssembly.AssemblyResolver);
+ SoapFormatter b = new SoapFormatter();
+ b.AssemblyFormat = FormatterAssemblyStyle.Simple;
+ GridModel t = b.Deserialize(s) as GridModel;
+ t.Modified = false;
+ return t;
+ }
+ finally
+ {
+ AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(SharedWindowsAssembly.AssemblyResolver);
+ }
+ }
+
+
+
+ public static AToolsType LoadSoap(Stream s)
+ {
+ try
+ {
+ AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(ToolsAssembly.AssemblyResolver);
+ SoapFormatter b = new SoapFormatter();
+ b.AssemblyFormat = FormatterAssemblyStyle.Simple;
+ AToolsType t = b.Deserialize(s) as AToolsType;
+ return t;
+ }
+ finally
+ {
+ AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(ToolsAssembly.AssemblyResolver);
+ }
+ }
+
+
+
+ public static AToolsType LoadSoap(Stream s)
+ {
+ try
+ {
+ AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(ToolsWindowsAssembly.AssemblyResolver);
+ SoapFormatter b = new SoapFormatter();
+ b.AssemblyFormat = FormatterAssemblyStyle.Simple;
+ AToolsType t = b.Deserialize(s) as AToolsType;
+ return t;
+ }
+ finally
+ {
+ AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(ToolsWindowsAssembly.AssemblyResolver);
+ }
+ }
+
+
+
+ BeginBlock();
+ // add action1
+ // .....
+ BeginBlock();
+ //......
+ EndBlock();
+ // add actionN
+ CloseBlock();
+
+
+ using Syncfusion.Windows.Forms.Tools;
+ using System.Data;
+ using System.Windows.Forms;
+ namespace WFApplication1
+ {
+ public partial class Form1 : Form
+ {
+ AutoComplete autoComplete1 = new AutoComplete();
+ TextBox textBox1 = new TextBox();
+ public Form1()
+ {
+ InitializeComponent();
+ // Set Auto Complete properties for target TextBox
+ this.autoComplete1.SetAutoComplete(this.textBox1, AutoCompleteModes.AutoSuggest);
+ this.autoComplete1.ParentForm = this;
+ //Create a data table
+ DataTable dt = new DataTable("Table1");
+ dt.Columns.Add("Country");
+ dt.Columns.Add("Capital");
+ // Create a data set
+ DataSet ds = new DataSet();
+ ds.Tables.Add(dt);
+ dt.Rows.Add(new string[] { "United Kingdom ", "London" });
+ dt.Rows.Add(new string[] { "USA", "Washington, D.C." });
+ dt.Rows.Add(new string[] { "Brazil", "Brasilia" });
+ DataView view = new DataView(dt);
+ // Setting data source to AutoComplete
+ this.autoComplete1.DataSource = view;
+ // Added by designer - Add the TextBox to the Form
+ this.Controls.Add(this.textBox1);
+ }
+ }
+ }
+
+
+ this.autoComplete1.DataSource =this.dataView1 ;
+ this.autoCompleteDataColumnInfo1 = new Syncfusion.Windows.Forms.Tools.AutoCompleteDataColumnInfo("EmployeeID", 100, true);
+ this.autoCompleteDataColumnInfo2 = new Syncfusion.Windows.Forms.Tools.AutoCompleteDataColumnInfo("LastName", 100, true);
+ this.autoCompleteDataColumnInfo3 = new Syncfusion.Windows.Forms.Tools.AutoCompleteDataColumnInfo("BirthDate", 100, true);
+ this.autoCompleteDataColumnInfo4 = new Syncfusion.Windows.Forms.Tools.AutoCompleteDataColumnInfo("City", 100, true);
+
+
+ this.autoComplete.AutoAddItem = true;
+ this.autoComplete.AutoSerialize = false;
+ this.autoComplete.CategoryName = "SomeCategory";
+
+
+ public class Form1 : System.Windows.Forms.Form
+ {
+ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
+ {
+ if (keyData == Keys.Escape)
+ {
+ if (this.ActiveControl == this.autoComplete1.ActiveFocusControl)
+ {
+ this.autoComplete1.CloseDropDown();
+ return true;
+ }
+ }
+ return base.ProcessCmdKey(ref msg, keyData);
+ }
+ }
+
+
+ foreach(DataRow dr in this.autoComplete1.TableData.Rows)
+ {
+ Console.WriteLine ("Rows "+dr[0]);
+ }
+
+
+ // Add a event to customize data added to history
+ this.autoComplete1.BeforeAddItem += new AutoCompleteAddItemCancelEventHandler(this.autoComplete1_BeforeAddItem);
+
+ // autoComplete1_BeforeAddItem
+ int columnCount = args.RowItem.Table.Columns.Count;
+ object [] itemarray = args.RowItem.ItemArray;
+
+ string itemText = (string)itemarray[0];// the url field
+ string nameText = (string)itemarray[1];// The name field
+
+ if(itemText.Substring(0,4) == "http")
+ {
+ if(nameText == null || nameText == String.Empty)
+ nameText = "Website";
+ }
+ else if(itemText.Substring(0,3) == "ftp")
+ {
+ if(nameText == null || nameText == String.Empty)
+ nameText = "FTP site";
+ }
+ else
+ args.Cancel = true;
+
+ itemarray[0] = itemText;
+ itemarray[1] = nameText;
+ args.RowItem.ItemArray = itemarray;
+
+
+ this.autoComplete1.SetAutoComplete(this.textBox1, Syncfusion.Windows.Forms.Tools.AutoCompleteModes.AutoSuggest);
+
+
+ AutoCompleteMode mode = this.autoComplete1.GetAutoComplete(this.comboBox1);
+ if(mode == AutoCompleteMode.Disabled)
+ this.autoComplete1.SetAutoComplete(this.comboBox1, Syncfusion.Windows.Forms.Tools.AutoCompleteMode.AutoSuggest);
+ else
+ this.autoComplete1.SetAutoComplete(this.comboBox1, AutoCompleteMode.Disabled);
+
+
+ private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
+ {
+ if (e.KeyChar == '@')
+ {
+ this.autoComplete1.CloseDropDown();
+ }
+ }
+
+
+ using Syncfusion.Windows.Forms.Tools;
+ using System.Windows.Forms;
+ namespace WFApplication1
+ {
+ public partial class Form1 : Form
+ {
+ ComboBoxAutoComplete comboBoxAutoComplete1 = new ComboBoxAutoComplete();
+ public Form1()
+ {
+ InitializeComponent();
+ this.comboBoxAutoComplete1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
+ this.comboBoxAutoComplete1.AutoCompleteCustomSource.AddRange(new string[] { "Custom", "Customizing", "Customizable" });
+ this.comboBoxAutoComplete1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
+ this.comboBoxAutoComplete1.AutoCompleteSource = AutoCompleteSource.CustomSource;
+ this.Controls.Add(comboBoxAutoComplete1);
+ }
+ }
+ }
+
+
+ // InitializeComponent sample
+ this.buttonEdit1 = new Syncfusion.Windows.Forms.Tools.ButtonEdit();
+ this.buttonEditChildButton1 = new Syncfusion.Windows.Forms.Tools.ButtonEditChildButton();
+ this.buttonEdit1.SuspendLayout();
+ this.SuspendLayout();
+ this.buttonEdit1.Buttons.Add(this.buttonEditChildButton1);
+ this.buttonEdit1.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.buttonEditChildButton1});
+ this.buttonEdit1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+ this.buttonEdit1.Location = new System.Drawing.Point(8, 16);
+ this.buttonEdit1.Name = "buttonEdit1";
+ this.buttonEdit1.SelectionLength = 0;
+ this.buttonEdit1.SelectionStart = 0;
+ this.buttonEdit1.ShowTextBox = true;
+ this.buttonEdit1.Size = new System.Drawing.Size(368, 22);
+ this.buttonEdit1.TabIndex = 0;
+ this.buttonEdit1.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
+ //
+ // buttonEditChildButton1
+ //
+ this.buttonEditChildButton1.ButtonAlign = Syncfusion.Windows.Forms.Tools.ButtonAlignment.Right;
+ this.buttonEditChildButton1.ButtonEditParent = this.buttonEdit1;
+ this.buttonEditChildButton1.ButtonType = Syncfusion.Windows.Forms.Tools.ButtonTypes.Browse;
+ this.buttonEditChildButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+ this.buttonEditChildButton1.Location = new System.Drawing.Point(352, 0);
+ this.buttonEditChildButton1.Name = "buttonEditChildButton1";
+ this.buttonEditChildButton1.PreferredWidth = 16;
+ this.buttonEditChildButton1.Size = new System.Drawing.Size(16, 22);
+ this.buttonEditChildButton1.TabIndex = 1;
+ this.buttonEditChildButton1.Click += new System.EventHandler(this.buttonEditChildButton1_Click);
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.ClientSize = new System.Drawing.Size(400, 273);
+ this.Controls.AddRange(new System.Windows.Forms.Control[] { this.buttonEdit1});
+ this.Text = "Syncfusion ButtonEdit Demo";
+ this.buttonEdit1.ResumeLayout(false);
+ this.ResumeLayout(false);
+ ' InitializeComponent sample
+ Me.buttonEdit1 = New Syncfusion.Windows.Forms.Tools.ButtonEdit()
+ Me.buttonEditChildButton1 = New Syncfusion.Windows.Forms.Tools.ButtonEditChildButton()
+ Me.buttonEdit1.SuspendLayout()
+ Me.SuspendLayout()
+ Me.buttonEdit1.Buttons.Add(Me.buttonEditChildButton1)
+ Me.buttonEdit1.Controls.AddRange(New System.Windows.Forms.Control() {Me.buttonEditChildButton1})
+ Me.buttonEdit1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
+ Me.buttonEdit1.Location = New System.Drawing.Point(8, 16)
+ Me.buttonEdit1.Name = "buttonEdit1"
+ Me.buttonEdit1.SelectionLength = 0
+ Me.buttonEdit1.SelectionStart = 0
+ Me.buttonEdit1.ShowTextBox = True
+ Me.buttonEdit1.Size = New System.Drawing.Size(368, 22)
+ Me.buttonEdit1.TabIndex = 0
+ Me.buttonEdit1.TextAlign = System.Windows.Forms.HorizontalAlignment.Left
+ '
+ ' buttonEditChildButton1
+ '
+ Me.buttonEditChildButton1.ButtonAlign = Syncfusion.Windows.Forms.Tools.ButtonAlignment.Right
+ Me.buttonEditChildButton1.ButtonEditParent = Me.buttonEdit1
+ Me.buttonEditChildButton1.ButtonType = Syncfusion.Windows.Forms.Tools.ButtonTypes.Browse
+ Me.buttonEditChildButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
+ Me.buttonEditChildButton1.Location = New System.Drawing.Point(352, 0)
+ Me.buttonEditChildButton1.Name = "buttonEditChildButton1"
+ Me.buttonEditChildButton1.PreferredWidth = 16
+ Me.buttonEditChildButton1.Size = New System.Drawing.Size(16, 22)
+ Me.buttonEditChildButton1.TabIndex = 1
+ AddHandler Me.buttonEditChildButton1.Click, New System.EventHandler(AddressOf buttonEditChildButton1_Click)
+ Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
+ Me.ClientSize = New System.Drawing.Size(400, 273)
+ Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.buttonEdit1})
+ Me.Text = "Syncfusion ButtonEdit Demo"
+ Me.buttonEdit1.ResumeLayout(False)
+ Me.ResumeLayout(False)
+ //InitializeComponent
+ // Create the Calculator Control
+ this.calculatorControl1 = new CalculatorControl();
+ this.textBox1 = new TextBox();
+ // Set the value of the calculator control
+ this.calculatorControl1.DoubleValue = 0;
+ // Set the border style for the control
+ this.calculatorControl1.BorderStyle = Border3DStyle.Raised;
+ // The flat style for the buttons
+ this.calculatorControl1.FlatStyle = FlatStyle.Standard;
+ // Set the size of the calculator
+ this.calculatorControl1.Size = new System.Drawing.Size(288, 232);
+ // Add a event handler for the ValueCalculated event of the child button
+ this.calculatorControl1.ValueCalculated += new Syncfusion.Windows.Forms.Tools.CalculatorControl.ValueCalculatedEventHandler(this.CodeGen_calculatorControl1_ValueCalculated);
+ // Add the CalculatorControl control to the form
+ this.Controls.Add(this.calculatorControl1);
+
+ 'InitializeComponent
+ ' Create the Calculator Control
+ Me.calculatorControl1 = New CalculatorControl()
+ Me.textBox1 = New TextBox()
+ ' Set the value of the calculator control
+ Me.calculatorControl1.DoubleValue = 0
+ ' Set the border style for the control
+ Me.calculatorControl1.BorderStyle = Border3DStyle.Raised
+ ' The flat style for the buttons
+ Me.calculatorControl1.FlatStyle = FlatStyle.Standard
+ ' Set the size of the calculator
+ Me.calculatorControl1.Size = New System.Drawing.Size(288, 232)
+ ' Add a event handler for the ValueCalculated event of the child button
+ AddHandler Me.calculatorControl1.ValueCalculated, New Syncfusion.Windows.Forms.Tools.CalculatorControl.ValueCalculatedEventHandler(AddressOf CodeGen_calculatorControl1_ValueCalculated)
+ ' Add the CalculatorControl control to the form
+ Me.Controls.Add(Me.calculatorControl1)
+ this.calculatorControl1.ValueCalculated += new Syncfusion.Windows.Forms.Tools.CalculatorControl.ValueCalculatedEventHandler(this.CodeGen_calculatorControl1_ValueCalculated);
+ calculatorControl1_ValueCalculated
+ if(arg.ErrorCondition == false)
+ this.textBox1.Text = arg.Value.ToString();
+ else
+ this.textBox1.Text = arg.Message;
+
+ AddHandler Me.calculatorControl1.ValueCalculated, New Syncfusion.Windows.Forms.Tools.CalculatorControl.ValueCalculatedEventHandler(AddressOf CodeGen_calculatorControl1_ValueCalculated)
+ 'calculatorControl1_ValueCalculated
+ If (arg.ErrorCondition = False) Then
+ Me.textBox1.Text = arg.Value.ToString
+ Else
+ Me.textBox1.Text = arg.Message
+ End If
+ // CurrencyEdit control
+ this.currencyEdit1 = new Syncfusion.Windows.Forms.Tools.CurrencyEdit();
+ //
+ // currencyEdit1
+ //
+ this.currencyEdit1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+ this.currencyEdit1.Location = new System.Drawing.Point(16, 80);
+ this.currencyEdit1.Name = "currencyEdit1";
+ this.currencyEdit1.SelectionLength = 0;
+ this.currencyEdit1.SelectionStart = 5;
+ this.currencyEdit1.ShowCalculator = true;
+ this.currencyEdit1.ShowTextBox = true;
+ this.currencyEdit1.Size = new System.Drawing.Size(304, 22);
+ this.currencyEdit1.TabIndex = 1;
+ this.currencyEdit1.Text = "$1.00";
+ this.currencyEdit1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+ // Add the CurrencyEdit control to the form
+ this.Controls.Add(this.currencyEdit1);
+
+ ' CurrencyEdit control
+ Me.currencyEdit1 = New Syncfusion.Windows.Forms.Tools.CurrencyEdit
+ '
+ ' currencyEdit1
+ '
+ Me.currencyEdit1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
+ Me.currencyEdit1.Location = New System.Drawing.Point(16, 80)
+ Me.currencyEdit1.Name = "currencyEdit1"
+ Me.currencyEdit1.SelectionLength = 0
+ Me.currencyEdit1.SelectionStart = 5
+ Me.currencyEdit1.ShowCalculator = true
+ Me.currencyEdit1.ShowTextBox = true
+ Me.currencyEdit1.Size = New System.Drawing.Size(304, 22)
+ Me.currencyEdit1.TabIndex = 1
+ Me.currencyEdit1.Text = "$1.00"
+ Me.currencyEdit1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
+ ' Add the CurrencyEdit control to the form
+ Me.Controls.Add(Me.currencyEdit1)
+
+
+ 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))
+ Font newFont = new Font(this.fontCombo.Text, 10.0);
+
+
+ Font newFont = new Font(this.fontCombo.Text, 10.0);
+
+
+ Font newFont = new Font(this.fontListBox.Text, 10.0);
+
+ This combo box is meant to be used in data bound mode where it will + show all the records and the different fields in the data source in a + multi column grid, in the dropdown.
+Data binding is done as usual through the
If you bind an array of objects of custom type then the public properties + in that type will correspond to each column in the dropdown multi-column grid.
+Note that in this version you cannot populate the
+ // InitializeComponent
+ // Create the Gradient Label
+ this.gradientLabel1 = new GradientLabel();
+ // Set formatting properties
+ this.gradientLabel1.Text = "Essential Suite Gradient Label";
+ this.gradientLabel1.BackgroundColor = new BrushInfo(Syncfusion.Drawing.GradientStyle.Vertical, System.Drawing.SystemColors.Highlight, System.Drawing.SystemColors.HighlightText);
+ this.gradientLabel1.BorderStyle = Border3DStyle.Etched;
+ this.gradientLabel1.Font = new Font("Microsoft Sans Serif", 14.25F, (System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic), System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
+ this.gradientLabel1.Location = new Point(24, 16);
+ this.gradientLabel1.Name = "gradientLabel1";
+ this.gradientLabel1.Size = new Size(440, 56);
+ this.gradientLabel1.TextAlign = ContentAlignment.MiddleCenter;
+ // Add the GradientLabel control to the form
+ this.Controls.Add(this.gradientLabel1);
+
+ ' InitializeComponent
+ ' Create the GradientLabel control.
+ Me.gradientLabel1 = New GradientLabel()
+ ' Set formatting properties
+ Me.gradientLabel1.Text = "Essential Suite Gradient Label"
+ Me.gradientLabel1.BackgroundColor = New BrushInfo(Syncfusion.Drawing.GradientStyle.Vertical, System.Drawing.SystemColors.Highlight, System.Drawing.SystemColors.HighlightText)
+ Me.gradientLabel1.BorderStyle = Border3DStyle.Etched
+ Me.gradientLabel1.Font = New Font("Microsoft Sans Serif", 14.25!, (System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.GraphicsUnit.Point, CType(0, Byte))
+ Me.gradientLabel1.Location = New Point(24, 16)
+ Me.gradientLabel1.Name = "gradientLabel1"
+ Me.gradientLabel1.Size = New Size(440, 56)
+ Me.gradientLabel1.TextAlign = ContentAlignment.MiddleCenter
+ ' Add the GradientLabel control to the form
+ Me.Controls.Add(Me.gradientLabel1)
+
+ If SortWithChildNodes property is set to true,the user can sort all the nodes including all the child nodes in the treeViewAdv.
+ The SortOrder of the Root should be specified for the sorting all nodes.
+ // Sorts only the root nodes.
+ private void button1_Click(object sender, System.EventArgs e)
+ {
+ this.treeViewAdv1.Nodes.Sort();
+ }
+ // Sort all the root nodes and the child nodes in the TreeviewAdv
+ private void button2_Click_1(object sender, System.EventArgs e)
+ {
+ this.treeViewAdv1.Root.SortOrder=SortOrder.Ascending;
+ this.treeViewAdv1.SortWithChildNodes=true;
+ this.treeViewAdv1.Root.Sort();
+ }
+
+ 'Sorts only the root nodes.
+ Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
+ Me.treeViewAdv1.Nodes.Sort()
+ End Sub
+ 'Sort all the root nodes and the child nodes in the TreeviewAdv
+ Private Sub button2_Click_1(ByVal sender As Object, ByVal e As System.EventArgs)
+ Me.treeViewAdv1.Root.SortOrder=SortOrder.Ascending
+ Me.treeViewAdv1.SortWithChildNodes=True
+ Me.treeViewAdv1.Root.Sort()
+ End Sub
+ The Item property in the argument is an array of MultiColumnTreeView nodes that + are currently selected.
+ You can choose to initiate an ole drag-and-drop operation in this event handler. +
+ // MultiColumnTreeView.ItemDrag event listener
+ private void treeViewAdv1_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e)
+ {
+ // Begin a drag and drop operation of the selected nodes (or some other data).
+ TreeNodeAdv[] nodes = e.Item as TreeNodeAdv[];
+ DragDropEffects result = this.DoDragDrop(nodes, DragDropEffects.Copy | DragDropEffects.Move);
+ // more app logic based on result...
+ }
+
+ ' MultiColumnTreeView.ItemDrag event listener
+ Private Sub treeViewAdv1_ItemDrag(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemDragEventArgs) Handles treeViewAdv2.ItemDrag
+ ' Begin a drag and drop operation of the selected nodes (or some other data).
+ Dim nodes As TreeNodeAdv() = CType(e.Item, TreeNodeAdv())
+ Dim result As DragDropEffects = Me.DoDragDrop(nodes, DragDropEffects.Copy Or DragDropEffects.Move)
+ ' more app logic based on result...
+ End Sub 'treeViewAdv1_ItemDrag '
+ The CollapseAll method collapses all the
The state of a TreeNodeAdv persists. For example, suppose that + a parent tree node is expanded. If the child tree nodes were not + previously collapsed, they will appear in their previously-expanded + state. Calling the CollapseAll method ensures that all the tree nodes + appear in the collapsed state.
The ExpandAll method expands all the
The CancelEditMode method cancels the edit mode when the node is in the EditingMode.
+ private void button1_Click(object sender, System.EventArgs e)
+ {
+ //Call the tree control's "GetNodeCount" method with true to
+ //get the total number of nodes in the tree
+ int TotalNodesInTree = this.treeViewAdv1.GetNodeCount( true );
+ MessageBox.Show( "Total nodes in tree = " + TotalNodesInTree.ToString());
+ }
+ //Add nodes
+ private void button2_Click(object sender, System.EventArgs e)
+ {
+ this.treeViewAdv1.SelectedNode.Nodes.Add(new TreeNodeAdv());
+ }
+ //Remove nodes
+ private void button3_Click(object sender, System.EventArgs e)
+ {
+ this.treeViewAdv1.SelectedNode.Parent.Nodes.Remove(this.treeViewAdv1.SelectedNode);
+ }
+
+ Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
+ ' Call the tree control's "GetNodeCount" method with true to
+ ' get the total number of nodes in the tree
+ Dim TotalNodesInTree As Integer = Me.treeViewAdv1.GetNodeCount(True)
+ MessageBox.Show("Total nodes in tree = " & TotalNodesInTree.ToString())
+ End Sub
+ 'Add nodes
+ Private Sub button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
+ Me.treeViewAdv1.SelectedNode.Nodes.Add(New TreeNodeAdv())
+ End Sub
+ 'Remove nodes
+ Private Sub button3_Click(ByVal sender As Object, ByVal e As System.EventArgs)
+ Me.treeViewAdv1.SelectedNode.Parent.Nodes.Remove(Me.treeViewAdv1.SelectedNode)
+ End Sub
+ The
The TreeNodeAdv label is set by setting the
You can specify images for the node using the
The order in which the tree node's contents are drawn is as follows:
+
+ The "State image" will be one of OpenImgIndex, ClosedImgIndex and NoChildrenImgIndex.
+
+ Selecting specific tree nodes and iterating through the
+ Tree nodes can be expanded to display the next level of child tree nodes.
+ The user can expand the tree node by pressing the plus (+) button next to the
+ TreeNodeAdv, if one is displayed or you can expand the TreeNodeAdv by calling the
+
+ The following example displays customer information in a
+ // Create a new ArrayList to hold the Customer objects.
+ private ArrayList customerArray = new ArrayList();
+ private void FillMyTreeView()
+ {
+ // Add customers to the ArrayList of Customer objects.
+ for(int x=0; x!=1000; x++)
+ {
+ customerArray.Add(new Customer("Customer" + x.ToString()));
+ }
+ // Add orders to each Customer object in the ArrayList.
+ foreach(Customer customer1 in customerArray)
+ {
+ for(int y=0; y!=15; y++)
+ {
+ customer1.CustomerOrders.Add(new Order("Order" + y.ToString()));
+ }
+ }
+
+ // Display a wait cursor while the TreeNodeAdvs are being created.
+ Cursor.Current = new Cursor("C:\\Cursors\\MyWait.cur");
+ // Clear the TreeViewAdv each time the method is called.
+ treeViewAdv1.Nodes.Clear();
+ // Add a root TreeNodeAdv for each Customer object in the ArrayList.
+ foreach(Customer customer2 in customerArray)
+ {
+ treeViewAdv1.Nodes.Add(new TreeNodeAdv(customer2.CustomerName));
+ // Add a child treenode for each Order object in the current Customer object.
+ foreach(Order order1 in customer2.CustomerOrders)
+ {
+ treeViewAdv1.Nodes[customerArray.IndexOf(customer2)].Nodes.Add(
+ new TreeNodeAdv(customer2.CustomerName + "." + order1.OrderID));
+ }
+ }
+ // Reset the cursor to the default for all controls.
+ Cursor.Current = Cursors.Default;
+ }
+
+ ' Create a new ArrayList to hold the Customer objects.
+ Private customerArray As New ArrayList()
+ Private Sub FillMyTreeView()
+ ' Add customers to the ArrayList of Customer objects.
+ Dim x As Integer
+ For x = 0 To 999
+ customerArray.Add(New Customer("Customer" + x.ToString()))
+ Next x
+
+ ' Add orders to each Customer object in the ArrayList.
+ Dim customer1 As Customer
+ For Each customer1 In customerArray
+ Dim y As Integer
+ For y = 0 To 14
+ customer1.CustomerOrders.Add(New Order("Order" + y.ToString()))
+ Next y
+ Next customer1
+
+ ' Display a wait cursor while the TreeNodeAdvs are being created.
+ Cursor.Current = New Cursor("C:\Cursors\MyWait.cur")
+
+ ' Clear the TreeViewAdv each time the method is called.
+ treeViewAdv1.Nodes.Clear()
+
+ ' Add a root TreeNodeAdv for each Customer object in the ArrayList.
+ Dim customer2 As Customer
+ For Each customer2 In customerArray
+ treeViewAdv1.Nodes.Add(New TreeNodeAdv(customer2.CustomerName))
+
+ ' Add a child TreeNodeAdv for each Order object in the current Customer object.
+ Dim order1 As Order
+ For Each order1 In customer2.CustomerOrders
+ treeViewAdv1.Nodes(customerArray.IndexOf(customer2)).Nodes.Add( _
+ New TreeNodeAdv(customer2.CustomerName + "." + order1.OrderID))
+ Next order1
+ Next customer2
+
+ ' Reset the cursor to the default for all controls.
+ Cursor.Current = System.Windows.Forms.Cursors.Default
+
+ ' Begin repainting the TreeView.
+ treeViewAdv1.EndUpdate()
+ End Sub 'FillMyTreeView
+ Note that setting this property will fire the
+ treeNodeAdv.NodeStyle.CheckState = CheckState.Checked;
+
+ treeNodeAdv.NodeStyle.CheckState = CheckState.Checked
+ Any Object derived type may be assigned to this property. If this property is + being set through the Windows Forms designer, only text may be assigned.
When the tree node is cloned, if this object is cloneable (implements ICloneable + interface) then it will be.
You can also use the more flexible
The path consists of the labels of all of the tree nodes that must be
+ navigated to get to this tree node, starting at the root tree node. The node
+ labels are separated by the delimiter character specified in the
+
You can also use the
This collection contains references to all selected nodes in the TreeViewAdv.
+ Adding a
Whenever a node is selected/deselected, either by user action or in code, + it is automatically added/removed from the SelectedNodes collection.
+This collection is read-only, which means you can add and remove elements but cannot change + the existing elements.
+You can listen to new selections being added to this collection using the collection's
+
Use this class (will be referred to as "tracker" below) only when you want to support dropping adjacent (above or below) to a node.
+ Otherwise simply listen to the
+ The usage semantics for the tracker is as follows: +
+ By default (when value is negative), the top 1/3 of the node will be considered the top edge.
+ This value will be used when you allow dropping before a node using
+ the
+ By default (when value is negative), the bottom 1/3 of the node will be considered the bottom edge.
+ This value will be used when you allow dropping below a node using the
+
This property will be ignored by the
+
+ RibbonControlAdv myRibbon = new RibbonControlAdv();
+ myRibbon. EnableSimplifiedLayoutMode = true;
+
+
+ Office2013ColorTable color = new Office2013ColorTable();
+ color.FileMenuForeColor = Color.Yellow;
+ this.ribbonControlAdv1.Office2013ColorTable = color;
+
+
+ Office2013ColorTable color = new Office2013ColorTable();
+ color.FileMenuHoverForeColor = Color.Yellow;
+ this.ribbonControlAdv1.Office2013ColorTable = color;
+
+
+ Office2016ColorTable color = new Office2016ColorTable();
+ color.FileMenuForeColor = Color.Yellow;
+ this.ribbonControlAdv1.Office2016ColorTable.Add(color);
+
+
+ Office2016ColorTable color = new Office2016ColorTable();
+ color.FileMenuHoverForeColor = Color.Yellow;
+ this.ribbonControlAdv1.Office2016ColorTable.Add(color);
+
+
+ public partial class Form1 : RibbonForm
+ {
+ public Form1()
+ {
+ InitializeComponent();
+
+ Button button = new Button();
+ button.Text = "Sign in";
+ this.HeaderItem = button;
+ }
+ }
+
+
+ public override StyleInfoSubObjectIdentity CreateSubObjectIdentity(StyleInfoProperty sip)
+ {
+ return new FormVisualStyleInfoSubObjectIdentity(this, sip);
+ }
+
+
+ public override StyleInfoSubObjectIdentity CreateSubObjectIdentity(StyleInfoProperty sip)
+ {
+ return new FormVisualStyleInfoSubObjectIdentity(this, sip);
+ }
+
+
+
+
+
+
+
+
+ private void splashControl1_SplashClosed(object sender, System.EventArgs e)
+ {
+ MessageBox.Show("The Splash screen has closed.");
+ }
+
+ Private Sub splashControl1_SplashClosed(ByVal sender As Object, ByVal e As System.EventArgs)
+ MessageBox.Show("The Splash screen has closed.")
+ End Sub
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ public class Form1 : System.Windows.Forms.Form
+ {
+ private Syncfusion.Windows.Forms.Tools.TabControlAdv TabControlAdv1;
+ private System.Windows.Forms.Label tab2label1;
+ private System.Windows.Forms.Button tab3Button;
+ private System.Windows.Forms.MonthCalendar tab3monthCalendar1;
+ private System.Windows.Forms.DateTimePicker tab3dateTimePicker1;
+ private System.Windows.Forms.Label tab3label;
+ private System.Windows.Forms.Label tab2label2;
+ private System.Windows.Forms.TextBox tab2textBox1;
+ private System.Windows.Forms.ListBox tab1listBox1;
+ private System.Windows.Forms.ComboBox tab1comboBox1;
+
+ private System.Windows.Forms.Label tab1label1;
+ private Syncfusion.Windows.Forms.Tools.TabPageAdv tab1;
+ private Syncfusion.Windows.Forms.Tools.TabPageAdv tab3;
+ private Syncfusion.Windows.Forms.Tools.TabPageAdv tab2;
+ private System.ComponentModel.IContainer components;
+
+ public Form1()
+ {
+ //
+ // Required for Windows Form Designer support
+ //
+ InitializeComponent();
+ }
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.tab2label1 = new System.Windows.Forms.Label();
+ this.tab1 = new Syncfusion.Windows.Forms.Tools.TabPageAdv();
+ this.tab1listBox1 = new System.Windows.Forms.ListBox();
+ this.tab1comboBox1 = new System.Windows.Forms.ComboBox();
+ this.tab1label1 = new System.Windows.Forms.Label();
+ this.tab3 = new Syncfusion.Windows.Forms.Tools.TabPageAdv();
+ this.tab3Button = new System.Windows.Forms.Button();
+ this.tab3monthCalendar1 = new System.Windows.Forms.MonthCalendar();
+ this.tab3dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
+ this.tab3label = new System.Windows.Forms.Label();
+ this.tab2 = new Syncfusion.Windows.Forms.Tools.TabPageAdv();
+ this.tab2label2 = new System.Windows.Forms.Label();
+ this.tab2textBox1 = new System.Windows.Forms.TextBox();
+ this.TabControlAdv1 = new Syncfusion.Tools.Windows.Forms.Tab.TabControlAdv();
+ this.tab1.SuspendLayout();
+ this.tab3.SuspendLayout();
+ this.tab2.SuspendLayout();
+ this.TabControlAdv1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // tab2label1
+ //
+ this.tab2label1.Dock = System.Windows.Forms.DockStyle.Top;
+ this.tab2label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
+ this.tab2label1.Name = "tab2label1";
+ this.tab2label1.Size = new System.Drawing.Size(373, 48);
+ this.tab2label1.TabIndex = 0;
+ this.tab2label1.Text = "Tab2";
+ this.tab2label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.tab2label1.Paint += new System.Windows.Forms.PaintEventHandler(this.TabPageAdv1_Paint);
+ //
+ // tab1
+ //
+ this.tab1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.tab1.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.tab1listBox1,
+ this.tab1comboBox1,
+ this.tab1label1});
+ this.tab1.Location = new System.Drawing.Point(1, 29);
+ this.tab1.Name = "tab1";
+ this.tab1.Size = new System.Drawing.Size(373, 257);
+ this.tab1.TabIndex = 0;
+ this.tab1.Text = "Tab 1";
+ this.tab1.ToolTipText = "0asdfasdf";
+ //
+ // tab1listBox1
+ //
+ this.tab1listBox1.Items.AddRange(new object[] {
+ "Item 1",
+ "Item 2",
+ "Item 3"});
+ this.tab1listBox1.Location = new System.Drawing.Point(8, 88);
+ this.tab1listBox1.Name = "tab1listBox1";
+ this.tab1listBox1.Size = new System.Drawing.Size(192, 147);
+ this.tab1listBox1.TabIndex = 2;
+ //
+ // tab1comboBox1
+ //
+ this.tab1comboBox1.DropDownWidth = 192;
+ this.tab1comboBox1.Location = new System.Drawing.Point(8, 56);
+ this.tab1comboBox1.Name = "tab1comboBox1";
+ this.tab1comboBox1.Size = new System.Drawing.Size(192, 21);
+ this.tab1comboBox1.TabIndex = 1;
+ this.tab1comboBox1.Text = "comboBox1";
+ //
+ // tab1label1
+ //
+ this.tab1label1.Dock = System.Windows.Forms.DockStyle.Top;
+ this.tab1label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
+ this.tab1label1.Name = "tab1label1";
+ this.tab1label1.Size = new System.Drawing.Size(371, 48);
+ this.tab1label1.TabIndex = 0;
+ this.tab1label1.Text = "Tab Page 1";
+ this.tab1label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // tab3
+ //
+ this.tab3.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.tab3Button,
+ this.tab3monthCalendar1,
+ this.tab3dateTimePicker1,
+ this.tab3label});
+ this.tab3.Location = new System.Drawing.Point(1, 29);
+ this.tab3.Name = "tab3";
+ this.tab3.Size = new System.Drawing.Size(373, 257);
+ this.tab3.TabIndex = 1;
+ this.tab3.Text = "Tab 3";
+ this.tab3.ToolTipText = "2asdfasdf";
+ this.tab3.Layout += new System.Windows.Forms.LayoutEventHandler(this.TabPageAdv2_Layout);
+ //
+ // tab3Button
+ //
+ this.tab3Button.Location = new System.Drawing.Point(264, 72);
+ this.tab3Button.Name = "tab3Button";
+ this.tab3Button.Size = new System.Drawing.Size(72, 24);
+ this.tab3Button.TabIndex = 3;
+ this.tab3Button.Text = "button1";
+ this.tab3Button.Click += new System.EventHandler(this.button1_Click);
+ //
+ // tab3monthCalendar1
+ //
+ this.tab3monthCalendar1.Location = new System.Drawing.Point(16, 96);
+ this.tab3monthCalendar1.Name = "tab3monthCalendar1";
+ this.tab3monthCalendar1.TabIndex = 2;
+ //
+ // tab3dateTimePicker1
+ //
+ this.tab3dateTimePicker1.Location = new System.Drawing.Point(8, 64);
+ this.tab3dateTimePicker1.Name = "tab3dateTimePicker1";
+ this.tab3dateTimePicker1.TabIndex = 1;
+ //
+ // tab3label
+ //
+ this.tab3label.Dock = System.Windows.Forms.DockStyle.Top;
+ this.tab3label.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
+ this.tab3label.Name = "tab3label";
+ this.tab3label.Size = new System.Drawing.Size(373, 48);
+ this.tab3label.TabIndex = 0;
+ this.tab3label.Text = "Tab3";
+ this.tab3label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // tab2
+ //
+ this.tab2.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.tab2label2,
+ this.tab2textBox1,
+ this.tab2label1});
+ this.tab2.Location = new System.Drawing.Point(1, 29);
+ this.tab2.Name = "tab2";
+ this.tab2.Size = new System.Drawing.Size(373, 257);
+ this.tab2.TabIndex = 2;
+ this.tab2.Text = "Tab2";
+ this.tab2.ToolTipText = "1asdfasdfasd";
+ //
+ // tab2label2
+ //
+ this.tab2label2.Location = new System.Drawing.Point(8, 96);
+ this.tab2label2.Name = "tab2label2";
+ this.tab2label2.Size = new System.Drawing.Size(112, 16);
+ this.tab2label2.TabIndex = 2;
+ this.tab2label2.Text = "Text Entry:";
+ //
+ // tab2textBox1
+ //
+ this.tab2textBox1.Location = new System.Drawing.Point(8, 120);
+ this.tab2textBox1.Multiline = true;
+ this.tab2textBox1.Name = "tab2textBox1";
+ this.tab2textBox1.Size = new System.Drawing.Size(368, 80);
+ this.tab2textBox1.TabIndex = 1;
+ this.tab2textBox1.Text = "textBox1";
+ //
+ // TabControlAdv1
+ //
+ this.TabControlAdv1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right);
+ this.TabControlAdv1.BackColor = System.Drawing.SystemColors.ActiveBorder;
+ this.TabControlAdv1.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.tab3,
+ this.tab2,
+ this.tab1});
+ this.TabControlAdv1.Cursor = System.Windows.Forms.Cursors.Default;
+ this.TabControlAdv1.HotTrack = true;
+ this.TabControlAdv1.ImageList = this.imageList1;
+ this.TabControlAdv1.ItemSize = new System.Drawing.Size(80, 30);
+ this.TabControlAdv1.Location = new System.Drawing.Point(40, 16);
+ this.TabControlAdv1.Name = "TabControlAdv1";
+ this.TabControlAdv1.ShowToolTips = true;
+ this.TabControlAdv1.Size = new System.Drawing.Size(376, 288);
+ this.TabControlAdv1.TabGap = 20;
+ this.TabControlAdv1.TabIndex = 4;
+ this.TabControlAdv1.TabStyle = typeof(Syncfusion.Tools.Windows.Forms.Tab.TabRenderer2D);
+ this.TabControlAdv1.TextAlignment = System.Drawing.StringAlignment.Near;
+ this.TabControlAdv1.UserMoveTabs = true;
+ this.TabControlAdv1.VSLikeScrollButton = true;
+ //
+ // Form1
+ //
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.ClientSize = new System.Drawing.Size(688, 309);
+ this.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.TabControlAdv1});
+ this.Name = "Form1";
+ this.Text = "Form1";
+ this.tab1.ResumeLayout(false);
+ this.tab3.ResumeLayout(false);
+ this.tab2.ResumeLayout(false);
+ this.TabControlAdv1.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+ }
+
+
+ Private Function Form1() As Public
+ '
+ ' Required for Windows Form Designer support
+ '
+ InitializeComponent()
+ End Function
+
+ Private Sub InitializeComponent()
+ Me.components = New System.ComponentModel.Container()
+ Me.tab2label1 = New System.Windows.Forms.Label()
+ Me.tab1 = New Syncfusion.Windows.Forms.Tools.TabPageAdv()
+ Me.tab1listBox1 = New System.Windows.Forms.ListBox()
+ Me.tab1comboBox1 = New System.Windows.Forms.ComboBox()
+ Me.tab1label1 = New System.Windows.Forms.Label()
+ Me.tab3 = New Syncfusion.Windows.Forms.Tools.TabPageAdv()
+ Me.tab3Button = New System.Windows.Forms.Button()
+ Me.tab3monthCalendar1 = New System.Windows.Forms.MonthCalendar()
+ Me.tab3dateTimePicker1 = New System.Windows.Forms.DateTimePicker()
+ Me.tab3label = New System.Windows.Forms.Label()
+ Me.tab2 = New Syncfusion.Windows.Forms.Tools.TabPageAdv()
+ Me.tab2label2 = New System.Windows.Forms.Label()
+ Me.tab2textBox1 = New System.Windows.Forms.TextBox()
+ Me.TabControlAdv1 = New Syncfusion.Tools.Windows.Forms.Tab.TabControlAdv()
+ Me.tab1.SuspendLayout()
+ Me.tab3.SuspendLayout()
+ Me.tab2.SuspendLayout()
+ Me.TabControlAdv1.SuspendLayout()
+ Me.SuspendLayout()
+
+ '
+ ' tab2label1
+ '
+ Me.tab2label1.Dock = System.Windows.Forms.DockStyle.Top
+ Me.tab2label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (CType((0), System.Byte)))
+ Me.tab2label1.Name = "tab2label1"
+ Me.tab2label1.Size = New System.Drawing.Size(373, 48)
+ Me.tab2label1.TabIndex = 0
+ Me.tab2label1.Text = "Tab2"
+ Me.tab2label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
+ Me.tab2label1.Paint += New System.Windows.Forms.PaintEventHandler(Me.TabPageAdv1_Paint)
+
+ '
+ ' tab1
+ '
+ Me.tab1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
+ Me.tab1.Controls.AddRange(New System.Windows.Forms.Control()
+ {Me.tab1listBox1,Me.tab1comboBox1,Me.tab1label1})
+ Me.tab1.Location = New System.Drawing.Point(1, 29)
+ Me.tab1.Name = "tab1"
+ Me.tab1.Size = New System.Drawing.Size(373, 257)
+ Me.tab1.TabIndex = 0
+ Me.tab1.Text = "Tab 1"
+ Me.tab1.ToolTipText = "0asdfasdf"
+ '
+ ' tab1listBox1
+ '
+ Me.tab1listBox1.Items.AddRange(New System.Windows.Forms.Control()
+ {Me.tab1listBox1,Me.tab1comboBox1,Me.tab1label1})
+ Dim Object() As Me.tab1listBox1.Items.AddRange(New string()
+ {
+ "Item 1",
+ "Item 2",
+ "Item 3"
+ })
+ Me.tab1listBox1.Location = New System.Drawing.Point(8, 88)
+ Me.tab1listBox1.Name = "tab1listBox1"
+ Me.tab1listBox1.Size = New System.Drawing.Size(192, 147)
+ Me.tab1listBox1.TabIndex = 2
+ '
+ ' tab1comboBox1
+ '
+ Me.tab1comboBox1.DropDownWidth = 192
+ Me.tab1comboBox1.Location = New System.Drawing.Point(8, 56)
+ Me.tab1comboBox1.Name = "tab1comboBox1"
+ Me.tab1comboBox1.Size = New System.Drawing.Size(192, 21)
+ Me.tab1comboBox1.TabIndex = 1
+ Me.tab1comboBox1.Text = "comboBox1"
+ '
+ ' tab1label1
+ '
+ Me.tab1label1.Dock = System.Windows.Forms.DockStyle.Top
+ Me.tab1label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (CType((0), System.Byte)))
+ Me.tab1label1.Name = "tab1label1"
+ Me.tab1label1.Size = New System.Drawing.Size(371, 48)
+ Me.tab1label1.TabIndex = 0
+ Me.tab1label1.Text = "Tab Page 1"
+ Me.tab1label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
+
+ Me.tab3.Controls.AddRange(New System.Windows.Forms.Control()
+ {Me.tab3Button,Me.tab3monthCalendar1,Me.tab3dateTimePicker1,Me.tab3label})
+ Me.tab3.Location = New System.Drawing.Point(1, 29)
+ Me.tab3.Name = "tab3"
+ Me.tab3.Size = New System.Drawing.Size(373, 257)
+ Me.tab3.TabIndex = 1
+ Me.tab3.Text = "Tab 3"
+ Me.tab3.ToolTipText = "2asdfasdf"
+ Me.tab3.Lay+= New System.Windows.Forms.LayoutEventHandler(Me.TabPageAdv2_Layout)
+ '
+ ' tab3Button
+ '
+ Me.tab3Button.Location = New System.Drawing.Point(264, 72)
+ Me.tab3Button.Name = "tab3Button"
+ Me.tab3Button.Size = New System.Drawing.Size(72, 24)
+ Me.tab3Button.TabIndex = 3
+ Me.tab3Button.Text = "button1"
+ Me.tab3Button.Click += New System.EventHandler(Me.button1_Click)
+ '
+ ' tab3monthCalendar1
+ '
+ Me.tab3monthCalendar1.Location = New System.Drawing.Point(16, 96)
+ Me.tab3monthCalendar1.Name = "tab3monthCalendar1"
+ Me.tab3monthCalendar1.TabIndex = 2
+ '
+ ' tab3dateTimePicker1
+ '
+ Me.tab3dateTimePicker1.Location = New System.Drawing.Point(8, 64)
+ Me.tab3dateTimePicker1.Name = "tab3dateTimePicker1"
+ Me.tab3dateTimePicker1.TabIndex = 1
+ '
+ ' tab3label
+ '
+ Me.tab3label.Dock = System.Windows.Forms.DockStyle.Top
+ Me.tab3label.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (CType((0), System.Byte)))
+ Me.tab3label.Name = "tab3label"
+ Me.tab3label.Size = New System.Drawing.Size(373, 48)
+ Me.tab3label.TabIndex = 0
+ Me.tab3label.Text = "Tab3"
+ Me.tab3label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
+ '
+ ' tab2
+ '
+ Me.tab2.Controls.AddRange(New System.Windows.Forms.Control()
+ {Me.tab2label2,Me.tab2textBox1,Me.tab2label1})
+ Me.tab2.Location = New System.Drawing.Point(1, 29)
+ Me.tab2.Name = "tab2"
+ Me.tab2.Size = New System.Drawing.Size(373, 257)
+ Me.tab2.TabIndex = 2
+ Me.tab2.Text = "Tab2"
+ Me.tab2.ToolTipText = "1asdfasdfasd"
+ '
+ ' tab2label2
+ '
+ Me.tab2label2.Location = New System.Drawing.Point(8, 96)
+ Me.tab2label2.Name = "tab2label2"
+ Me.tab2label2.Size = New System.Drawing.Size(112, 16)
+ Me.tab2label2.TabIndex = 2
+ Me.tab2label2.Text = "Text Entry:"
+ '
+ ' tab2textBox1
+ '
+ Me.tab2textBox1.Location = New System.Drawing.Point(8, 120)
+ Me.tab2textBox1.Multiline = True
+ Me.tab2textBox1.Name = "tab2textBox1"
+ Me.tab2textBox1.Size = New System.Drawing.Size(368, 80)
+ Me.tab2textBox1.TabIndex = 1
+ Me.tab2textBox1.Text = "textBox1"
+ '
+ ' TabControlAdv1
+ '
+ Me.TabControlAdv1.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.TabControlAdv1.Cursor = System.Windows.Forms.Cursors.Default
+ Me.TabControlAdv1.HotTrack = True
+ Me.TabControlAdv1.ImageList = Me.imageList1
+ Me.TabControlAdv1.ItemSize = New System.Drawing.Size(80, 30)
+ Me.TabControlAdv1.Location = New System.Drawing.Point(40, 16)
+ Me.TabControlAdv1.Name = "TabControlAdv1"
+ Me.TabControlAdv1.ShowToolTips = True
+ Me.TabControlAdv1.Size = New System.Drawing.Size(376, 288)
+ Me.TabControlAdv1.TabGap = 20
+ Me.TabControlAdv1.TabIndex = 4
+ Me.TabControlAdv1.TabStyle = Type.GetType(Syncfusion.Tools.Windows.Forms.Tab.TabRenderer2D)
+ Me.TabControlAdv1.TextAlignment = System.Drawing.StringAlignment.Near
+ Me.TabControlAdv1.UserMoveTabs = True
+ Me.TabControlAdv1.VSLikeScrollButton = True
+ '
+ ' Form1
+ '
+ Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
+ Me.ClientSize = New System.Drawing.Size(688, 309)
+ Me.Controls.AddRange(New System.Windows.Forms.Control()
+ {Me.TabControlAdv1})
+ Me.Name = "Form1"
+ Me.Text = "Form1"
+ Me.tab1.ResumeLayout(False)
+ Me.tab3.ResumeLayout(False)
+ Me.tab2.ResumeLayout(False)
+ Me.TabControlAdv1.ResumeLayout(False)
+ Me.ResumeLayout(False)
+ End Sub
+
+
+ //Loading TabState from xml file(TabState.xml located in Application folder)
+ AppStateSerializer serializer = new AppStateSerializer(SerializeMode.XMLFile, "TabState");
+ this.tabControlAdv1.LoadState(serializer);
+
+
+ 'Loading TabState from xml file(TabState.xml located in Application folder)
+ Dim serializer As New AppStateSerializer(SerializeMode.XMLFile, "TabState")
+ Me.tabControlAdv1.LoadState(serializer)
+
+
+ //Saving TabState to xml file(TabState.xml located in Application folder)
+ AppStateSerializer serializer =new AppStateSerializer(SerializeMode.XMLFile, "TabState");
+ this.tabControlAdv1.SaveState(serializer);
+ serializer.PersistNow();
+
+
+ 'Saving TabState to xml file(TabState.xml located in Application folder)
+ Dim serializer As New AppStateSerializer(SerializeMode.XMLFile, "TabState")
+ Me.tabControlAdv1.SaveState(serializer)
+ serializer.PersistNow()
+
+
+ // Make sure to set the "3D" tab style, turn on the HotTrack property and handle
+ // the DrawItem event of the tab control.
+ private void InitializeComponent()
+ {
+ ....
+ this.TabControlAdv1.HotTrack = true;
+ this.TabControlAdv1.TabStyle = typeof(Syncfusion.Windows.Forms.Tools.TabRenderer3D);
+ this.TabControlAdv1.DrawItem += new Syncfusion.Windows.Forms.Tools.DrawTabEventHandler(this.Tab_DrawItemYahooMessengerLike);
+ ....
+ }
+ private void Tab_DrawItemYahooMessengerLike(object sender, DrawTabEventArgs drawItemInfo)
+ {
+ // Draw the default background and interior in all cases.
+ drawItemInfo.DrawBackground();
+ drawItemInfo.DrawInterior();
+
+ // The border should be drawn only when the item is selected or highlighted.
+ if(((int)drawItemInfo.State & ((int)DrawItemState.Selected | (int)DrawItemState.HotLight)) > 0)
+ {
+ // Draw the borders
+ drawItemInfo.DrawBorders();
+ }
+ }
+
+
+ ' Make sure to set the "3D" tab style, turn on the HotTrack property and handle
+ ' the DrawItem event of the tab control.
+ Private Sub InitializeComponent()
+ Me.TabControlAdv1.HotTrack = True
+ Me.TabControlAdv1.TabStyle = GetType(Syncfusion.Windows.Forms.Tools.TabRenderer3D)
+ Me.TabControlAdv1.DrawItem += New Syncfusion.Windows.Forms.Tools.DrawTabEventHandler(Me.Tab_DrawItemYahooMessengerLike)
+ End Sub 'InitializeComponent
+
+ Private Sub Tab_DrawItemYahooMessengerLike(sender As Object, drawItemInfo As DrawTabEventArgs)
+ ' Draw the default background and interior in all cases.
+ drawItemInfo.DrawBackground()
+ drawItemInfo.DrawInterior()
+
+ ' The border should be drawn only when the item is selected or highlighted.
+ If(CInt(drawItemInfo.State) And(CInt(DrawItemState.Selected) Or CInt(DrawItemState.HotLight))) > 0 Then
+ ' Draw the borders
+ drawItemInfo.DrawBorders()
+ End If
+ End Sub 'Tab_DrawItemYahooMessengerLike
+
+
+ public Form1()
+ {
+ this.tabPage1 = new TabPageAdv();
+ // Invokes the TabControlAdv() constructor to create the tabControl1 object.
+ this.tabControl1 = new TabControlAdv();
+
+ this.tabControl1.Controls.Add(tabPage1);
+ this.Controls.Add(tabControl1);
+ }
+
+
+ Public Sub New()
+ Me.tabPage1 = New TabPageAdv()
+ ' Invokes the TabControlAdv() constructor to create the tabControl1 object.
+ Me.tabControl1 = New TabControlAdv()
+ Me.tabControl1.Controls.Add(tabPage1)
+ Me.Controls.Add(tabControl1)
+ End Sub 'New
+
+
+ private void InitMyTabs()
+ {
+ this.tabControl1 = new TabControlAdv();
+ this.tabPage1 = new TabPageAdv();
+ this.tabPage2 = new TabPageAdv();
+ this.tabPage3 = new TabPageAdv();
+
+ // Positions tabs on the left side of tabControl1.
+ // this.tabControl1.Alignment = System.Windows.Forms.TabAlignment.Left;
+
+ // Sets the tabs to appear in 2D mode.
+ tabControl1.TabStyle = typeof(TabRenderer2D);
+
+ // Highlights TabPage.Text when the mouse passes over tabs.
+ this.tabControl1.HotTrack = true;
+
+ // Set the relative alignment between the images and text in a tab
+ this.tabControl1.ImageAlignmentR = RelativeImageAlignment.BelowText;
+
+ // Allows more than one row of tabs.
+ // this.tabControl1.Multiline = true;
+
+ // Creates a cushion of 22 pixels around TabPage.Text strings.
+ this.tabControl1.Padding = new System.Drawing.Point(22, 22);
+
+ // Makes the tab width definable.
+ this.tabControl1.SizeMode = Syncfusion.Windows.Forms.Tools.TabSizeMode.Fixed;
+
+ // Sizes the tabs of tabControl1.
+ this.tabControl1.ItemSize = new Size(90, 64); // Make sure to take into account the padding values.
+
+ // To rotate text when aligned vertically.
+ this.tabControl1.RotateTextWhenVertical = true;
+
+ // Allows the user to move the tabs by simply dragging and dropping
+ this.tabControl1.UserMoveTabs = true;
+
+ // Draws the scroll buttons Visual Studio MDI Tabs like.
+ this.tabControl1.VSLikeScrollButton = true;
+
+ this.tabControl1.Controls.AddRange(new Control[] {
+ this.tabPage1,
+ this.tabPage2,
+ this.tabPage3});
+ this.tabControl1.Location = new Point(16, 24);
+ this.tabControl1.SelectedIndex = 0;
+ this.tabControl1.Size = new Size(248, 232);
+
+ this.tabPage1.Text = "Tab1";
+ this.tabPage2.Text = "Tab2";
+ this.tabPage3.Text = "Tab3";
+
+ this.Size = new Size(300,300);
+ this.Controls.AddRange(new Control[] {
+ this.tabControl1});
+
+ // Selects tabPage1 using SelectedIndex.
+ this.tabControl1.SelectedIndex = 1;
+
+ // Shows ToolTipText when the mouse passes over tabs.
+ this.tabControl1.ShowToolTips = true;
+ }
+ Private Sub InitMyTabs()
+
+ Me.tabControl1 = New TabControlAdv()
+ Me.tabPage1 = New TabPageAdv()
+ Me.tabPage2 = New TabPageAdv()
+ Me.tabPage3 = New TabPageAdv()
+ ' Positions tabs on the left side of tabControl1.
+ ' this.tabControl1.Alignment = System.Windows.Forms.TabAlignment.Left;
+ ' Sets the tabs to appear in 2D mode.
+ tabControl1.TabStyle = GetType(TabRenderer2D)
+ ' Highlights TabPage.Text when the mouse passes over tabs.
+ Me.tabControl1.HotTrack = True
+ ' Set the relative alignment between the images and text in a tab
+ Me.tabControl1.ImageAlignmentR = RelativeImageAlignment.BelowText
+ ' Allows more than one row of tabs.
+ ' this.tabControl1.Multiline = true;
+ ' Creates a cushion of 22 pixels around TabPage.Text strings.
+ Me.tabControl1.Padding = New System.Drawing.Point(22, 22)
+ ' Makes the tab width definable.
+ Me.tabControl1.SizeMode = Syncfusion.Windows.Forms.Tools.TabSizeMode.Fixed
+ ' Sizes the tabs of tabControl1.
+ Me.tabControl1.ItemSize = New Size(90, 64)
+ ' Make sure to take into account the padding values.
+ ' To rotate text when aligned vertically.
+ Me.tabControl1.RotateTextWhenVertical = True
+ ' Allows the user to move the tabs by simply dragging and dropping
+ Me.tabControl1.UserMoveTabs = True
+ ' Draws the scroll buttons Visual Studio MDI Tabs like.
+ Me.tabControl1.VSLikeScrollButton = True
+ Me.tabControl1.Controls.AddRange(New Control() {Me.tabPage1, Me.tabPage2, Me.tabPage3})
+ Me.tabControl1.Location = New Point(16, 24)
+ Me.tabControl1.SelectedIndex = 0
+ Me.tabControl1.Size = New Size(248, 232)
+ Me.tabPage1.Text = "Tab1"
+ Me.tabPage2.Text = "Tab2"
+ Me.tabPage3.Text = "Tab3"
+ Me.Size = New Size(300, 300)
+ Me.Controls.AddRange(New Control() {Me.tabControl1})
+ ' Selects tabPage1 using SelectedIndex.
+ Me.tabControl1.SelectedIndex = 1
+ ' Shows ToolTipText when the mouse passes over tabs.
+ Me.tabControl1.ShowToolTips = True
+
+ End Sub
+ public Form1()
+ {
+ this.tabControl1 = new TabControlAdv();
+
+ // Invokes the TabPage() constructor to create the tabPage1 object.
+ this.tabPage1 = new Syncfusion.Windows.Forms.Tools.TabPageAdv();
+ this.tabControl1.Controls.AddRange(new Control[] {
+ this.tabPage1});
+ this.tabControl1.Location = new Point(25, 25);
+ this.tabControl1.Size = new Size(250, 250);
+ this.ClientSize = new Size(300, 300);
+ this.Controls.AddRange(new Control[] {
+ this.tabControl1});
+ }
+
+
+ Public Sub New()
+ Me.tabControl1 = New TabControlAdv()
+ ' Invokes the TabPage() constructor to create the tabPage1 object.
+ Me.tabPage1 = New Syncfusion.Windows.Forms.Tools.TabPageAdv()
+ Me.tabControl1.Controls.AddRange(New Control() {Me.tabPage1})
+ Me.tabControl1.Location = New Point(25, 25)
+ Me.tabControl1.Size = New Size(250, 250)
+ Me.ClientSize = New Size(300, 300)
+ Me.Controls.AddRange(New Control() {Me.tabControl1})
+ End Sub 'New
+
+
+ public void MyTabs()
+ {
+ this.tabControl1 = new TabControlAdv();
+ // Invokes the TabPageAdv() constructor to create the tabPage1 object.
+ this.tabPage1 = new Syncfusion.Windows.Forms.ToolsTabPageAdv();
+ this.tabControl1.Controls.Add(tabPage1);
+ this.Controls.Add(tabControl1);
+ }
+
+ public Form1()
+ {
+ MyTabs();
+ }
+
+
+ public void MyTabs()
+ {
+ this.tabControl1 = new TabControlAdv();
+ string tabPageName = "myTabPage";
+
+ // Invokes the TabPageAdv() constructor to create the tabPage1 object.
+ this.tabPage1 = new Syncfusion.Windows.Forms.Tools.TabPageAdv(tabPageName);
+
+ this.tabControl1.Controls.Add(tabPage1);
+ this.Controls.Add(tabControl1);
+ }
+
+ public Form1()
+ {
+ MyTabs();
+ }
+
+
+ private void tabControlAdv1_SelectedIndexChanging(object sender, Syncfusion.Windows.Forms.Tools.SelectedIndexChangingEventArgs args)
+ {
+ TabPageAdv newPage = this.tabControlAdv1.TabPages[args.NewSelectedIndex];
+ if(newPage == this.tab1)
+ {
+ MessageBox.Show("Cannot select tab page 1");
+ args.Cancel = true;
+ }
+ }
+
+
+ Private Sub tabControlAdv1_SelectedIndexChanging(ByVal sender As Object, ByVal args As Syncfusion.Windows.Forms.Tools.SelectedIndexChangingEventArgs)
+ Dim NewPage As TabPageAdv = Me.tabControlAdv1.TabPages(args.NewSelectedIndex)
+ If NewPage = Me.tab1 Then
+ MessageBox.Show("Cannot select tab page 1")
+ args.Cancel = True
+ End If
+ End Sub
+
+ The Item property in the argument is an array of TreeViewAdv nodes that + are currently selected.
++ You can choose to initiate an ole drag-and-drop operation in this event handler. +
+
+ // TreeViewAdv.ItemDrag event listener
+ private void treeViewAdv1_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e)
+ {
+ // Begin a drag and drop operation of the selected nodes (or some other data).
+ TreeNodeAdv[] nodes = e.Item as TreeNodeAdv[];
+ DragDropEffects result = this.DoDragDrop(nodes, DragDropEffects.Copy | DragDropEffects.Move);
+ // more application logic based on result...
+ }
+
+
+ ' TreeViewAdv.ItemDrag event listener
+ Private Sub treeViewAdv1_ItemDrag(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemDragEventArgs) Handles treeViewAdv2.ItemDrag
+ ' Begin a drag and drop operation of the selected nodes (or some other data).
+ Dim nodes As TreeNodeAdv() = CType(e.Item, TreeNodeAdv())
+ Dim result As DragDropEffects = Me.DoDragDrop(nodes, DragDropEffects.Copy Or DragDropEffects.Move)
+ ' more application logic based on result...
+ End Sub 'treeViewAdv1_ItemDrag '
+
+
+ If SortWithChildNodes property is set to true,the user can sort all the nodes including all the child nodes in the treeViewAdv.
+ The SortOrder of the Root should be specified for the sorting all nodes.
+ //Sorts only the root nodes.
+ private void button1_Click(object sender, System.EventArgs e)
+ {
+ this.treeViewAdv1.Nodes.Sort();
+ }
+ //Sort all the root nodes and the child nodes in the TreeviewAdv
+ private void button2_Click_1(object sender, System.EventArgs e)
+ {
+ this.treeViewAdv1.Root.SortOrder=SortOrder.Ascending;
+ this.treeViewAdv1.SortWithChildNodes=true;
+ this.treeViewAdv1.Root.Sort();
+ }
+
+
+ 'Sorts only the root nodes.
+ Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
+ Me.treeViewAdv1.Nodes.Sort()
+ End Sub
+ 'Sort all the root nodes and the child nodes in the TreeviewAdv
+ Private Sub button2_Click_1(ByVal sender As Object, ByVal e As System.EventArgs)
+ Me.treeViewAdv1.Root.SortOrder=SortOrder.Ascending
+ Me.treeViewAdv1.SortWithChildNodes=True
+ Me.treeViewAdv1.Root.Sort()
+ End Sub
+
+
+ TreeViewAdv treeViewAdv1 = new TreeViewAdv();
+ treeViewAdv1.DisplayMember = "Place";
+ treeViewAdv1.ParentMember = "ParentID";
+ treeViewAdv1.ChildMember = "ChildID";
+ treeViewAdv1.DataSource = dataTable2;
+ //Sets the selected item form datatable
+ treeViewAdv1.SelectedItem = dataTable2.Rows[1];
+
+ The following example shows how to set the value of the SelectedItem property.
+ The CollapseAll method collapses all the
The state of a TreeNodeAdv persists. For example, suppose that + a parent tree node is expanded. If the child tree nodes were not + previously collapsed, they will appear in their previously-expanded + state. Calling the CollapseAll method ensures that all the tree nodes + appear in the collapsed state.
+The ExpandAll method expands all the
The CancelEditMode method cancels the edit mode when the node is in the EditingMode.
+
+ private void button1_Click(object sender, System.EventArgs e)
+ {
+ //Call the tree control's "GetNodeCount" method with true to
+ //get the total number of nodes in the tree
+ int TotalNodesInTree = this.treeViewAdv1.GetNodeCount( true );
+ MessageBox.Show( "Total nodes in tree = " + TotalNodesInTree.ToString());
+ }
+ //Add nodes
+ private void button2_Click(object sender, System.EventArgs e)
+ {
+ this.treeViewAdv1.SelectedNode.Nodes.Add(new TreeNodeAdv());
+ }
+ //Remove nodes
+ private void button3_Click(object sender, System.EventArgs e)
+ {
+ this.treeViewAdv1.SelectedNode.Parent.Nodes.Remove(this.treeViewAdv1.SelectedNode);
+ }
+
+
+ Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
+ ' Call the tree control's "GetNodeCount" method with true to
+ ' get the total number of nodes in the tree
+ Dim TotalNodesInTree As Integer = Me.treeViewAdv1.GetNodeCount(True)
+ MessageBox.Show("Total nodes in tree = " & TotalNodesInTree.ToString())
+ End Sub
+ 'Add nodes
+ Private Sub button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
+ Me.treeViewAdv1.SelectedNode.Nodes.Add(New TreeNodeAdv())
+ End Sub
+ 'Remove nodes
+ Private Sub button3_Click(ByVal sender As Object, ByVal e As System.EventArgs)
+ Me.treeViewAdv1.SelectedNode.Parent.Nodes.Remove(Me.treeViewAdv1.SelectedNode)
+ End Sub
+
+ The
The TreeNodeAdv label is set by setting the
You can specify images for the node using the
The order in which the tree node's contents are drawn is as follows:
+
+
+ The "State image" will be one of OpenImgIndex, ClosedImgIndex and NoChildrenImgIndex.
+
+ Selecting specific tree nodes and iterating through the
+ Tree nodes can be expanded to display the next level of child tree nodes.
+ The user can expand the tree node by pressing the plus (+) button next to the
+ TreeNodeAdv, if one is displayed or you can expand the TreeNodeAdv by calling the
+
+ The following example displays customer information in a
+ // Create a new ArrayList to hold the Customer objects.
+ private ArrayList customerArray = new ArrayList();
+
+ private void FillMyTreeView()
+ {
+ // Add customers to the ArrayList of Customer objects.
+ for(int x=0; x!=1000; x++)
+ {
+ customerArray.Add(new Customer("Customer" + x.ToString()));
+ }
+ // Add orders to each Customer object in the ArrayList.
+ foreach(Customer customer1 in customerArray)
+ {
+ for(int y=0; y!=15; y++)
+ {
+ customer1.CustomerOrders.Add(new Order("Order" + y.ToString()));
+ }
+ }
+
+ // Display a wait cursor while the TreeNodeAdvs are being created.
+ Cursor.Current = new Cursor("C:\\Cursors\\MyWait.cur");
+ // Clear the TreeViewAdv each time the method is called.
+ treeViewAdv1.Nodes.Clear();
+ // Add a root TreeNodeAdv for each Customer object in the ArrayList.
+ foreach(Customer customer2 in customerArray)
+ {
+ treeViewAdv1.Nodes.Add(new TreeNodeAdv(customer2.CustomerName));
+ // Add a child treenode for each Order object in the current Customer object.
+ foreach(Order order1 in customer2.CustomerOrders)
+ {
+ treeViewAdv1.Nodes[customerArray.IndexOf(customer2)].Nodes.Add(
+ new TreeNodeAdv(customer2.CustomerName + "." + order1.OrderID));
+ }
+ }
+ // Reset the cursor to the default for all controls.
+ Cursor.Current = Cursors.Default;
+ }
+
+
+ ' Create a new ArrayList to hold the Customer objects.
+ Private customerArray As New ArrayList()
+ Private Sub FillMyTreeView()
+ ' Add customers to the ArrayList of Customer objects.
+ Dim x As Integer
+ For x = 0 To 999
+ customerArray.Add(New Customer("Customer" + x.ToString()))
+ Next x
+
+ ' Add orders to each Customer object in the ArrayList.
+ Dim customer1 As Customer
+ For Each customer1 In customerArray
+ Dim y As Integer
+ For y = 0 To 14
+ customer1.CustomerOrders.Add(New Order("Order" + y.ToString()))
+ Next y
+ Next customer1
+
+ ' Display a wait cursor while the TreeNodeAdvs are being created.
+ Cursor.Current = New Cursor("C:\Cursors\MyWait.cur")
+
+ ' Clear the TreeViewAdv each time the method is called.
+ treeViewAdv1.Nodes.Clear()
+
+ ' Add a root TreeNodeAdv for each Customer object in the ArrayList.
+ Dim customer2 As Customer
+ For Each customer2 In customerArray
+ treeViewAdv1.Nodes.Add(New TreeNodeAdv(customer2.CustomerName))
+
+ ' Add a child TreeNodeAdv for each Order object in the current Customer object.
+ Dim order1 As Order
+ For Each order1 In customer2.CustomerOrders
+ treeViewAdv1.Nodes(customerArray.IndexOf(customer2)).Nodes.Add( _
+ New TreeNodeAdv(customer2.CustomerName + "." + order1.OrderID))
+ Next order1
+ Next customer2
+
+ ' Reset the cursor to the default for all controls.
+ Cursor.Current = System.Windows.Forms.Cursors.Default
+
+ ' Begin repainting the TreeView.
+ treeViewAdv1.EndUpdate()
+ End Sub 'FillMyTreeView
+
+ Note that setting this property will fire the
+ treeNodeAdv.NodeStyle.CheckState = CheckState.Checked;
+
+
+ treeNodeAdv.NodeStyle.CheckState = CheckState.Checked
+
+ Any Object derived type may be assigned to this property. If this property is + being set through the Windows Forms designer, only text may be assigned.
+When the tree node is cloned, if this object is cloneable (implements ICloneable + interface) then it will be.
+You can also use the more flexible
The path consists of the labels of all of the tree nodes that must be
+ navigated to get to this tree node, starting at the root tree node. The node
+ labels are separated by the delimiter character specified in the
+
You can also use the
This collection contains references to all selected nodes in the TreeViewAdv.
+ Adding a
Whenever a node is selected/deselected, either by user action or in code, + it is automatically added/removed from the SelectedNodes collection.
+This collection is read-only, which means you can add and remove elements but cannot change + the existing elements.
+You can listen to new selections being added to this collection using the collection's
+
+ TreeViewPrintDocument printDocument = new TreeViewPrintDocument(this.treeViewAdv1);
+ printDocument.Print();
+
+ Use the following code for print preview:
+
+ TreeViewPrintDocument printDocument = new TreeViewPrintDocument(this.treeViewAdv1);
+ printDocument.PrintPreview();
+
+ Use this class (will be referred to as "tracker" below) only when you want to support dropping adjacent (above or below) to a node.
+ Otherwise simply listen to the
+ The usage semantics for the tracker is as follows: +
+
+ By default (when value is negative), the top 1/3 of the node will be considered the top edge.
+ This value will be used when you allow dropping before a node using
+ the
+ By default (when value is negative), the bottom 1/3 of the node will be considered the bottom edge.
+ This value will be used when you allow dropping below a node using the
+
The specified Label, if not a child of the BannerPanel will then be made a + child of the BannerPanel.
+The specified Label, if not a child of the BannerPanel will then be made a + child of the BannerPanel.
+
+
+
+
+
+
+ When this property is true, the expanded states of the child task bar boxes are + cached as the users expands/collapses them and when this control is disposed, the cached + state is persisted in the Isolated Storage.
++ When the application loads again and when child task bar boxes are added to this control, + the saved state is reapplied on the task bar boxes. +
++ State is saved in the Isolated Storage of the system, scoped by the current user identity. +
+You can also optionally, explicitly control the persistent store and/or
+ the time of persistence using explicit calls to
Call this method whenever you want to save the current expanded state of + the task bar boxes in the Isolated Storage.
+Note that you do not have to call this method to persist state. You could
+ use the
Call this method whenever you want to save the current expanded state of + the task bar boxes in a custom location (instead of the default Isolated Storage).
+Note that you do not have to call this method to persist state. You could
+ use the
Call this method whenever you want to load the saved expanded states of + the task bar boxes from the Isolated Storage.
+Note that you do not have to call this method to persist state. You could
+ use the
Call this method whenever you want to load the saved expanded states of + the task bar boxes from a specific location.
+Note that you do not have to call this method to persist state. You could
+ use the
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + The Essential Tools CommandBars framework implements a hosting environment that can be used for + creating toolbars, statusbars and rebars similar to those that are present + in the Microsoft Visual Studio.NET IDE and the Microsoft Office XP product suite. + A CommandBar, similar to Win32/MFC control bars, is purely a container control that + is responsible only for it's layout state and it is the client window, such as a ToolBar, + StatusBar or any other Windows Forms control, that provides the CommandBar with it's + functional identity. +
+CommandBars have two basic states - a docked state and a floating state. + In the docked state, the CommandBars are usually aligned along one of the borders + (left, right, top or bottom) of the host form. Depending upon the preferences set, + the bar can either take up an entire row as in the case of a menu or share it's + space with other bars within a particular row as with toolbars and rebars. By default, + a docked CommandBar has a gripper and a drop-down button with a customizable click event. + The gripper can be used to reposition the bar within a row, move it between rows and to drag + it out of the frame and float as a separate window. In the docked mode, when the row + width is adequate, the CommandBars are usually sized to their maximum length. However, + reducing the frame width/height will, based on the user-setting, force the CommandBar to + reduce in size while retaining the same height or wrap thereby increasing the bar height. + The wrapping mode is particularly useful for toolbars and is fully customizable. + In the floating state, the CommandBar is parented by a floating window + that can dragged around the desktop. A floating CommandBar can be redocked to it's host + by either double-clicking it or by dragging it over one of the edges of the host form. +
+
+ The CommandBarController class, as the name implies, serves as a form-scope controller for all the CommandBars.
+ Attributes that are common across all CommandBars within a host form, such as the
+
+ private void InitializeCommandBars()
+ {
+ // Create the CommandBarController
+ this.commandBarController1 = new Syncfusion.Windows.Forms.Tools.CommandBarController();
+ ((System.ComponentModel.ISupportInitialize)(this.commandBarController1)).BeginInit();
+
+ // Set the CommandBarController's host form
+ this.commandBarController1.HostForm = this;
+ this.commandBarController1.PersistState = true;
+
+ // Create the CommandBar control
+ this.commandBarAddress = new Syncfusion.Windows.Forms.Tools.CommandBar();
+
+ // Set the CommandBar Layout/Behavior/Appearance attributes
+ this.commandBarAddress.DockBorder = Syncfusion.Windows.Forms.Tools.DockBorder.Top;
+ this.commandBarAddress.HideDropDownButton = true;
+ this.commandBarAddress.MaxLength = 400;
+ this.commandBarAddress.MinHeight = 26;
+ this.commandBarAddress.MinLength = 50;
+ this.commandBarAddress.Name = "commandBarAddress";
+ this.commandBarAddress.RowIndex = 1;
+ this.commandBarAddress.RowOffset = 1;
+ this.commandBarAddress.Text = "Address";
+
+ // Create the ComboBox control and add it to the CommandBars Controls collection
+ this.comboBox1 = new System.Windows.Forms.ComboBox();
+ this.commandBarAddress.Controls.AddRange(new System.Windows.Forms.Control[] {this.comboBox1});
+
+ // Add the CommandBar to the CommandBarController.CommandBars collection
+ this.commandBarController1.CommandBars.Add(this.commandBarAddress);
+
+ ((System.ComponentModel.ISupportInitialize)(this.commandBarController1)).EndInit();
+ }
+ Private Sub InitializeCommandBars()
+
+ ' Create the CommandBarController
+ Me.commandBarController1 = New Syncfusion.Windows.Forms.Tools.CommandBarController(Me.components)
+ CType(Me.commandBarController1, System.ComponentModel.ISupportInitialize).BeginInit()
+
+ ' Set the CommandBarController's host form
+ Me.commandBarController1.HostForm = Me
+ Me.commandBarController1.PersistState = True
+
+ ' Create the CommandBar control
+ Me.commandBarAddress = New Syncfusion.Windows.Forms.Tools.CommandBar()
+
+ ' Set the CommandBar Layout/Behavior/Appearance attributes
+ Me.commandBarAddress.DockState = Syncfusion.Windows.Forms.Tools.CommandBarDockState.Top
+ Me.commandBarAddress.MaxLength = 400
+ Me.commandBarAddress.MinHeight = 26
+ Me.commandBarAddress.MinLength = 50
+ Me.commandBarAddress.Name = "commandBarAddress"
+ Me.commandBarAddress.RowIndex = 1
+ Me.commandBarAddress.RowOffset = 1
+ Me.commandBarAddress.Text = "Address"
+
+ ' Create the ComboBox control and add it to the CommandBars Controls collection
+ Me.comboBox1 = New System.Windows.Forms.ComboBox()
+ Me.commandBarAddress.Controls.AddRange(New System.Windows.Forms.Control() {Me.comboBox1})
+
+ ' Add the CommandBar to the CommandBarControllers CommandBars // collection
+ Me.commandBarController1.CommandBars.Add(Me.commandBarAddress)
+
+ CType(Me.commandBarController1, System.ComponentModel.ISupportInitialize).EndInit()
+
+ End Sub+ This enumeration has the FlagsAttribute that allows a bitwise combination of its member values. +
++ The CommandBar class is a part of the Essential Tools CommandBars framework and allows + Windows Forms developers to add to their applications dockable command bars similar to + those that are present in the Microsoft Visual Studio.NET and Office XP environments. +
++ The CommandBar, similar to to the MFC/Win32 control bars, is a container control that primarily + serves as a host for some other Windows Forms control. The CommandBar class implements the hosting + and layout logic while the contained control provides the functional significance. +
+
+ See
+ A
+ ControlBars are supported through the XPMenus framework and can be added to any form that has been initialized
+ with a
+ NOTE: The main caption for floating windows is rendered by the Win32 system and cannot be customized. +
++ The Essential Tools Docking Windows framework enables developers to add docking windows, similar + to those found in the Microsoft Visual Studio.NET IDE, to their Windows Forms applications. At the + most basic level a docking window may be defined as a control that attaches itself to a host form's + border, is capable of being dragged around and docked to different edges within the form and can also be + dragged off the host form and floated as an individual top-level window. The docking + framework allows just about any child control on a form to be made into a fully qualified + docking window. The framework, in addition to the core docking interactions, implements + some highly advanced features such as multiple docking levels, nested docking, tabbed docking, + tear-off tabs, autohide mode, state persistence etc. To facilitate the addition of these + complex features, the DockingManager has a full-fledged WYSIWYG visual designer that enables + developers to create the exact docking layout that they desire without having to write a single line of code. +
+The DockingManager class is the central component of the Essential Tools Docking Windows implementation. + The class coordinates and facilitates the multitude of complex interactions that take place between + a dockable control and it's host form as well as between the dockable controls themselves. + DockingManagers are form-centric and adding an instance of the component to a form makes the + form into a 'dock-enabled' host. The DockingManager is implemented as an Extender Provider and + upon adding it to a Form or UserControl, the controls that are immediate children of the container qualify for + the docking services provided by the docking framework. +
+
+ The 'EnableDocking' (
+ NOTE: The layout initialization code shown here is required only when docking window is being used programmatically. + When using the designer, the layout state will automatically be written to the application's resource file. +
+
+ private void InitializeDockingWindows()
+ {
+ // Create the DockingManager instance and set this form as the host form.
+ this.dockingManager = new Syncfusion.Windows.Forms.Tools.DockingManager(this.components);
+ this.dockingManager.BeginInit();
+ this.dockingManager.HostForm = this;
+
+ // Disable state persistence
+ this.dockingManager.PersistState = false;
+ // Enable display of the default context menus
+ this.dockingManager.EnableContextMenu = true;
+ // Set the imagelist that will provide the icons for the docking windows.
+ this.dockingManager.ImageList = this.ilDocking;
+
+ // Dock listbox1 to the left border of the form and with an initial
+ // width of 175 units.
+ // NOTE - Calling DockControl() on a control for the first time,
+ // will initialize it as a docking window. This is the equivalent of
+ // the DockingManager.SetEnableDocking() call.
+ this.dockingManager.DockControl(this.listBox1, this,
+ Syncfusion.Windows.Forms.Tools.Syncfusion.Windows.Forms.Tools.DockingStyle.Left, 175);
+ // Set the text to be displayed in the dockingwindow caption
+ this.dockingManager.SetDockLabel(this.listBox1, "ListBox 1");
+ // The image index used for this control
+ this.dockingManager.SetDockIcon(this.listBox1, 0);
+
+ // Now dock listbox2 as a tab onto listbox1
+ this.dockingManager.DockControl(this.listBox2, this.listBox1,
+ Syncfusion.Windows.Forms.Tools.Syncfusion.Windows.Forms.Tools.DockingStyle.Tabbed, 175);
+ this.dockingManager.SetDockLabel(this.listBox2, "ListBox 2");
+ this.dockingManager.SetDockIcon(this.listBox2, 1);
+
+ // Dock the treeView to the right border of the form with a width of 150.
+ this.dockingManager.DockControl(this.treeView1, this, Syncfusion.Windows.Forms.Tools.DockingStyle.Right, 150);
+ // Set treeView1 to start off in the AutoHide position.
+ this.dockingManager.SetAutoHideMode(this.treeView1, true);
+ this.dockingManager.SetDockLabel(this.treeView1, "TreeView");
+ this.dockingManager.SetDockIcon(this.treeView1, 2);
+
+ // Set checkedListBox1 to be initially in a floating position.
+ Rectangle rcfrm = this.Bounds;
+ this.dockingManager.FloatControl(this.checkedListBox1,
+ new Rectangle(rcfrm.Right+25,rcfrm.Bottom-250,175,300));
+ this.dockingManager.SetDockLabel(this.checkedListBox1, "Checked ListBox");
+ this.dockingManager.SetDockIcon(this.checkedListBox1, 3);
+ this.dockingManager.EndInit();
+ }
+ Private Sub InitializeDockingWindows()
+
+ ' Create the DockingManager instance and set this form as the host form.
+ Me.dockingManager = New Syncfusion.Windows.Forms.Tools.DockingManager(Me.components)
+ Me.dockingManager.BeginInit()
+ Me.dockingManager.HostForm = Me
+
+ ' Disable state persistence
+ Me.dockingManager.PersistState = False
+ ' Enable display of the default context menus
+ Me.dockingManager.EnableContextMenu = True
+ ' Set the imagelist that will provide the icons for the docking windows.
+ Me.dockingManager.ImageList = Me.ilDocking
+
+ ' Dock listbox1 to the left border of the form and with an initial
+ ' width of 175 units.
+ ' NOTE - Calling DockControl() on a control for the first time,
+ ' will initialize it as a docking window. This is the equivalent of
+ ' the DockingManager.SetEnableDocking() call.
+ Me.dockingManager.DockControl(Me.listBox1, Me, Syncfusion.Windows.Forms.Tools.Syncfusion.Windows.Forms.Tools.DockingStyle.Left, 175)
+ ' Set the text to be displayed in the dockingwindow caption
+ Me.dockingManager.SetDockLabel(Me.listBox1, "ListBox 1")
+ ' The image index used for this control
+ Me.dockingManager.SetDockIcon(Me.listBox1, 0)
+
+ ' Now dock listbox2 as a tab onto listbox1
+ Me.dockingManager.DockControl(Me.listBox2, Me.listBox1, Syncfusion.Windows.Forms.Tools.Syncfusion.Windows.Forms.Tools.DockingStyle.Tabbed, 175)
+ Me.dockingManager.SetDockLabel(Me.listBox2, "ListBox 2")
+ Me.dockingManager.SetDockIcon(Me.listBox2, 1)
+
+ ' Dock the treeView to the right border of the form with a width of 150.
+ Me.dockingManager.DockControl(Me.treeView1, Me, Syncfusion.Windows.Forms.Tools.DockingStyle.Right, 150)
+ ' Set treeView1 to start off in the AutoHide position.
+ Me.dockingManager.SetAutoHideMode(Me.treeView1, True)
+ Me.dockingManager.SetDockLabel(Me.treeView1, "TreeView")
+ Me.dockingManager.SetDockIcon(Me.treeView1, 2)
+
+ ' Set checkedListBox1 to be initially in a floating position.
+ Dim rcfrm As Rectangle
+ rcfrm = Me.Bounds
+ Me.dockingManager.FloatControl(Me.checkedListBox1, New Rectangle((rcfrm.Right + 25), (rcfrm.Bottom - 250), 175, 300))
+ Me.dockingManager.SetDockLabel(Me.checkedListBox1, "Checked ListBox")
+ Me.dockingManager.SetDockIcon(Me.checkedListBox1, 3)
+ Me.dockingManager.EndInit()
+
+ End Sub
+ private void dockingManager1_DragAllow(object sender, Syncfusion.Windows.Forms.Tools.DragAllowEventArgs arg){
+ //Check the control which is going to be dragged and cancel according to that
+ if(arg.Control==panel1)
+ arg.Cancel=true;
+ }
+
+
+ Private Sub dockingManager1_DragAllow(ByVal sender As Object, ByVal arg As Syncfusion.Windows.Forms.Tools.DragAllowEventArgs) Handles dockingManager1.DragAllow
+ 'Check the control which is going to be dragged and cancel according to that
+ If(arg.Control==panel1)Then
+ arg.Cancel=true;
+ EndIf
+ End Sub
+
+
+ private void dockingManager1_DockVisibilityChanging(object sender, Syncfusion.Windows.Forms.Tools.DockVisibilityChangingEventArgs arg){
+ //Check the control and cancel closing.
+ if (arg.Control == panel1)
+ arg.Cancel = true;
+ }
+
+
+ Private Sub dockingManager1_DockVisibilityChanging(ByVal sender As Object, ByVal arg As Syncfusion.Windows.Forms.Tools.DockContextMenuEventArgs) Handles dockingManager1.DockVisibilityChanging
+ 'Check the control and cancel closing.
+ if (arg.Control == Panel1) Then
+ arg.Cancel = true;
+ End If
+ End Sub
+
+
+ private void dockingManager1_AutoHideAnimationStart(object sender, Syncfusion.Windows.Forms.Tools.AutoHideAnimationEventArgs arg)
+ {
+ if (arg.DockBorder == DockStyle.Left || arg.DockBorder == DockStyle.Right)
+ Syncfusion.Windows.Forms.Tools.DockingManager.AnimationStep = arg.Bounds.Width;
+ else
+ Syncfusion.Windows.Forms.Tools.DockingManager.AnimationStep = arg.Bounds.Height;
+ }
+
+
+ Private Sub DockingManager1_AutoHideAnimationStart(ByVal sender As System.Object, ByVal arg As Syncfusion.Windows.Forms.Tools.AutoHideAnimationEventArgs) Handles DockingManager1.AutoHideAnimationStart
+ If (arg.DockBorder = DockStyle.Left Or arg.DockBorder = DockStyle.Right) Then
+ Syncfusion.Windows.Forms.Tools.DockingManager.AnimationStep = arg.Bounds.Width
+ Else
+ Syncfusion.Windows.Forms.Tools.DockingManager.AnimationStep = arg.Bounds.Height
+ End If
+ End Sub
+
+
+ private void docMgr_DockContextMenu(object sender, Syncfusion.Windows.Forms.Tools.DockContextMenuEventArgs arg){
+ //Checking the control and assigning an empty menu
+ if (arg.Owner == panel1)
+ arg.ContextMenu = new Syncfusion.Windows.Forms.Tools.XPMenus.PopupMenu();
+ }
+
+
+ Private Sub dockingManager1_DockContextMenu(ByVal sender As Object, ByVal arg As Syncfusion.Windows.Forms.Tools.DockContextMenuEventArgs) Handles dockingManager1.DockContextMenu
+ 'Checking the control and assigning an empty menu
+ If (arg.Owner == panel1) Then
+ arg.ContextMenu = new Syncfusion.Windows.Forms.Tools.XPMenus.PopupMenu()
+ End If
+ End Sub
+
+
+ private void dockingManager1_NewDockStateEndLoad(object sender, EventArgs e)
+ {
+ DockStateLoadEventArgs dsle = (DockStateLoadEventArgs)e;
+ Console.WriteLine(dsle.LoadResult.ToString());
+ }
+
+
+ Private Sub DockingManager_NewDockStateEndLoad(ByVal sender As Object, ByVal e As System.EventArgs) Handles DockingManager.NewDockStateEndLoad
+ Dim dsle As DockStateLoadEventArgs = CType(e, DockStateLoadEventArgs)
+ Console.WriteLine(dsle.LoadResult)
+ End Sub
+
+
+ void dockingManager1_ProvideGraphicsItems(object sender, Syncfusion.Windows.Forms.Tools.ProvideGraphicsItemsEventArgs arg)
+ {
+ if (arg.Control == panel1) //Checks if the control is panel1
+ {
+ if (arg.IsActiveCaption)//Different drawing for active and inactive states
+ {
+ arg.CaptionBackground = Brushes.Blue;
+ arg.CaptionFont = new Font("Times New Roman", 10);
+ arg.CaptionForeground = Color.White;
+ }
+ else{
+ arg.CaptionBackground = Brushes.Gray;
+ arg.CaptionFont = new Font("Times New Roman", 10);
+ arg.CaptionForeground = Color.White;
+ }
+ }
+ }
+
+
+ Private Sub DockingManager1_ProvideGraphicsItems(ByVal sender As System.Object, ByVal arg As Syncfusion.Windows.Forms.Tools.ProvideGraphicsItemsEventArgs) Handles DockingManager1.ProvideGraphicsItems
+ If arg.Control Is Panel1 Then ' Checks if the control is panel1
+ If arg.IsActiveCaption then 'Different drawing for active and inactive states
+ arg.CaptionBackground = Brushes.Blue
+ arg.CaptionFont = New Font("Times New Roman", 10)
+ arg.CaptionForeground = Color.White
+ Else
+ arg.CaptionBackground = Brushes.Gray
+ arg.CaptionFont = New Font("Times New Roman", 10)
+ arg.CaptionForeground = Color.White
+ End If
+ End If
+ End Sub
+
+
+ private void DockingManager1_TabGroupCreating(object sender, Syncfusion.Windows.Forms.Tools.TabGroupCreatingEventArgs arg){
+ //Check the TargetItem and cancel creating document tab group.
+ if (arg.TargetItem == panel1)
+ arg.Cancel = true;
+ //Check the Orientation and cancel creating document tab group.
+ if (arg.Orientation== Orientation.Horizontal)
+ arg.Cancel = true;
+ }
+
+
+ Private Sub DockingManager1_TabGroupCreating(ByVal sender As Object, ByVal arg As Syncfusion.Windows.Forms.Tools.TabGroupCreatingEventArgs) Handles dockingManager1.DockVisibilityChanging
+ 'Check the control and cancel creating document tab group
+ if (arg.TargetItem == Panel1) Then
+ arg.Cancel = true
+ 'Check the Orientation and cancel creating document tab group.
+ if (arg.Orientation== Orientation.Horizontal) Then
+ arg.Cancel = true
+ End If
+ End Sub
+
+
+ private void dockingManager1_AutoHideAnimationStart(object sender, Syncfusion.Windows.Forms.Tools.AutoHideAnimationEventArgs arg)
+ {
+ if (arg.DockBorder == DockStyle.Left || arg.DockBorder == DockStyle.Right)
+ Syncfusion.Windows.Forms.Tools.DockingManager.AnimationStep = arg.Bounds.Width;
+ else
+ Syncfusion.Windows.Forms.Tools.DockingManager.AnimationStep = arg.Bounds.Height;
+ }
+
+
+ Private Sub DockingManager1_AutoHideAnimationStart(ByVal sender As System.Object, ByVal arg As Syncfusion.Windows.Forms.Tools.AutoHideAnimationEventArgs) Handles DockingManager1.AutoHideAnimationStart
+ If (arg.DockBorder = DockStyle.Left Or arg.DockBorder = DockStyle.Right) Then
+ Syncfusion.Windows.Forms.Tools.DockingManager.AnimationStep = arg.Bounds.Width
+ Else
+ Syncfusion.Windows.Forms.Tools.DockingManager.AnimationStep = arg.Bounds.Height
+ End If
+ End Sub
+
+
+ dockingManager1.BrowsingKey = Keys.F10;
+ dockingManager1.BrowsingKey=((System.Windows.Forms.Keys)(Enum.Parse(typeof(Keys), "F12, Shift, Control"))); //This will set Ctrl+Shift+F12 as browsing key
+
+
+ DockingManager1.BrowsingKey = Keys.F10
+ Me.DockingManager1.BrowsingKey = CType(Enum.Parse(typeof(Keys), "F12, Shift, Control"),System.Windows.Forms.Keys) 'This will set Ctrl+Shift+F12 as browsing key
+
+
+ IEnumerator ienum = this.dockingManager1.Controls;
+ ArrayList dockedctrls = new ArrayList();
+ while(ienum.MoveNext())
+ dockedctrls.Add(ienum.Current);
+ foreach(Control ctrl in dockedctrls)
+ Console.WriteLine(ctrl.ToString());
+
+
+ Dim ienum As IEnumerator = Me.dockingManager1.Controls
+ Dim dockedctrls As ArrayList = New ArrayList()
+ Do While ienum.MoveNext()
+ dockedctrls.Add(ienum.Current)
+ Loop
+ Dim ctrl As Control
+ For Each ctrl In dockedctrls
+ Console.WriteLine(ctrl.ToString())
+ Next
+
+
+ The DockToFill option should not be set when the host form is an MDIContainer or if it contains an instance of the
+
+ NOTE: This property applies only when the DockingManager is hosted, either directly or indirectly through a ContainerControl, in an MDI child form. +
++ NOTE: This property applies only when the DockingManager is hosted in a ContainerControl. +
+
+ dockingManager1.LockHostFormUpdate();
+ dockingManager1.LoadDockState();
+ dockingManager1.UnlockHostFormUpdate();
+
+
+ DockingManager1.LockHostFormUpdate()
+ DockingManager1.LoadDockState()
+ DockingManager1.UnlockHostFormUpdate()
+
+
+ //Loading DockState from IsolatedStorage
+ AppStateSErializer appstser=new AppStateSerializer(SerializeMode.IsolatedStorage, null);
+ dockingManager1.LoadDockState(appstser);
+ //Loading DockState from xml file(DockState.xml located in Application folder)
+ AppStateSerializer appstser =new AppStateSerializer(SerializeMode.XMLFile, "DockState");
+ dockingManager1.LoadDockState(appstser);
+
+
+ 'Loading DockState from IsolatedStorage
+ Dim appstser As New AppStateSerializer(SerializeMode.IsolatedStorage, Nothing)
+ dockingManager1.LoadDockState(appstser)
+ 'Loading DockState from xml file(DockState.xml located in Application folder)
+ Dim appstser As New AppStateSerializer(SerializeMode.XMLFile, "DockState")
+ dockingManager1.LoadDockState(appstser)
+
+
+ //Saving DockState to IsolatedStorage
+ AppStateSErializer appstser=new AppStateSerializer(SerializeMode.IsolatedStorage, null);
+ dockingManager1.SaveDockState(appstser);
+ appstser.PersistNow();
+ //Saving DockState to xml file(DockState.xml located in Application folder)
+ AppStateSerializer appstser =new AppStateSerializer(SerializeMode.XMLFile, "DockState");
+ dockingManager1.SaveDockState(appstser);
+ appstser.PersistNow();
+
+
+ 'Saving DockState to IsolatedStorage
+ Dim appstser As New AppStateSerializer(SerializeMode.IsolatedStorage, Nothing)
+ dockingManager1.SaveDockState(appstser)
+ appstser.PersistNow()
+ 'Saving DockState to xml file(DockState.xml located in Application folder)
+ Dim appstser As New AppStateSerializer(SerializeMode.XMLFile, "DockState")
+ dockingManager1.SaveDockState(appstser)
+ appstser.PersistNow()
+
+
+ //Float control panel1 in specified manner.
+ dockingManager1.FloatControl(panel1,new Rectangle(1,1,200,200));
+
+
+ 'Float control panel1 in specified manner.
+ DockingManager1.FloatControl(Panel1,new Rectangle(1,1,200,200))
+
+
+ //Float control panel1 in specified manner.
+ dockingManager1.FloatControl(panel1,new Rectangle(1,1,200,200),true);
+
+
+ 'Float control panel1 in specified manner.
+ DockingManager1.FloatControl(Panel1,new Rectangle(1,1,200,200),true)
+
+
+ //Add the document container to the hostform of the
+ dockingManager1.UseDocumentContainer= true;
+ //Dock the panel1 in document state.
+ dockingManager1.DockAsDocument(panel1));
+
+
+ 'Add the document container to the hostform of the
+ DockingManager1.UseDocumentContainer= true
+ 'Dock the panel1 in document state.
+ DockingManager1.dockingManager1.DockAsDocument(panel1))
+
+
+ //Add the document container to the hostform of the
+ dockingManager1.EnableDocumentMode= true;
+ //Dock the panel1 in document state.
+
+ dockingManager1.FreezeToDocumentState(panel1, true);
+
+
+ 'Add the document container to the hostform of the
+ DockingManager1.EnableDocumentMode= true
+ 'Dock the panel1 in document state.
+ DockingManager1.dockingManager1.FreezeToDocumentState(panel1, true))
+
+
+ //Code to dock a control to left of HostForm with width 100
+ dockingManager1.DockControl(panel1,this,Syncfusion.Windows.Forms.Tools.DockingStyle.Left,100);
+ //Code to dock a control(panel1) to top of another docked control(panel2).
+ dockingManager1.DockControl(panel1,panel2,Syncfusion.Windows.Forms.Tools.DockingStyle.Top,100);//panel1 will take space from panel2 at the top
+ //Code to dock a control(panel1) into another docked control(panel2) in tabbed style
+ dockingManager1.DockControl(panel1,panel2,Syncfusion.Windows.Forms.Tools.DockingStyle.Tabbed,100);
+ //Code to Dock a control(panel1) into another docked control(panel2) in tabbed style with whole tab group
+ dockingManager1.DockControl(panel1,panel2,DockingStyle.Tabbed,150,false);
+
+
+ 'Code to dock a control to left side of HostForm with width 100
+ DockingManager1.DockControl(Panel1,this,Syncfusion.Windows.Forms.Tools.DockingStyle.Left,100);
+ 'Code to dock a control(Panel1) to top of another docked control(Panel2).
+ DockingManager1.DockControl(panel1,panel2,Syncfusion.Windows.Forms.Tools.DockingStyle.Top,100);//Panel1 will take space from Panel2 at the top
+ 'Code to dock a control(Panel1) into another docked control(Panel2) in tabbed style
+ DockingManager1.DockControl(Panel1,Panel2,Syncfusion.Windows.Forms.Tools.DockingStyle.Tabbed,100);
+ 'Code to Dock a control(Panel1) into another docked control(Panel2) in tabbed style with whole tab group
+ DockingManager1.DockControl(Panel1,Panel2,DockingStyle.Tabbed,150,false);
+
+ + NOTE: The DockingClientPanel should not be used in MDIContainer forms as the equivalent functionality is provided by + the MDIClient window. +
+
+ this.tabbedMDIManager = new TabbedMDIManager();
+ this.tabbedMDIManager.AttachToMdiContainer(this);
+
+ Me.tabbedMDIManager = New TabbedMDIManager()
+ Me.tabbedMDIManager.AttachToMdiContainer(Me)
+
+ // Append menus to the standard mdi tab context menu
+ ParentBarItem contextMenuItem = new ParentBarItem();
+ BarItem newDocItem = new BarItem();
+ newDocItem.Click += new System.EventHandler(this.addDoc1_Click);
+ newDocItem.Text = "Custom Item: Insert New Doc";
+ newDocItem.MergeOrder = 30;
+ contextMenuItem.Items.Add(newDocItem);
+ BarItem exitItem = new BarItem();
+ exitItem.Click += new System.EventHandler(this.FileExit_Clicked);
+ exitItem.Text = "CustomItem: Exit";
+ exitItem.MergeOrder = 30;
+ contextMenuItem.Items.Add(exitItem);
+ contextMenuItem.BeginGroupAt(newDocItem);
+ // Items in this ParentBarItem will be merged with the standard context menu ParentBarItem of the mdi tab.
+ tabbedMDIManager.ContextMenuItem = contextMenuItem;
+ ' Append menus to the standard mdi tab context menu
+ Dim contextMenuItem As ParentBarItem
+ contextMenuItem = New ParentBarItem()
+ Dim newDocItem As BarItem
+ newDocItem = New BarItem()
+ AddHandler newDocItem.Click, New System.EventHandler(AddressOf addDoc1_Click)
+ newDocItem.Text = "Custom Item: Insert New Doc"
+ newDocItem.MergeOrder = 30
+ contextMenuItem.Items.Add(newDocItem)
+ Dim exitItem As BarItem
+ exitItem = New BarItem()
+ AddHandler exitItem.Click, New System.EventHandler(AddressOf FileExit_Clicked)
+ exitItem.Text = "CustomItem: Exit"
+ exitItem.MergeOrder = 30
+ contextMenuItem.Items.Add(exitItem)
+ contextMenuItem.BeginGroupAt(newDocItem)
+ ' Items in this ParentBarItem will be merged with the standard context menu ParentBarItem of the mdi tab.
+ tabbedMDIManager.ContextMenuItem = contextMenuItem
+ foreach(Form form in this.tabbedMDIManager.MdiChildren)
+ {
+ children += form.Text + "\r\n";
+ }
+ Dim form As Form
+ For Each form In Me.tabbedMDIManager.MdiChildren
+ ' Process form
+ Next
+ public MainForm() {
+ //
+ // Required for Windows Form Designer support
+ //
+ InitializeComponent();
+ tabbedMDIManager = new TabbedMDIManager();
+ //tabbedMDIManager.UseIconsInTabs = false;
+ //Add Window Menu
+ this.miWindow = mainMenu.MenuItems.Add("Window");
+ miWindow.MergeOrder = 10;
+ miWindow.MenuItems.Add("Cascade", new System.EventHandler(this.WindowCascade_Clicked));
+ miWindow.MenuItems.Add("Tile Horizontal", new System.EventHandler(this.WindowTileH_Clicked));
+ miWindow.MenuItems.Add("Tile Vertical", new System.EventHandler(this.WindowTileV_Clicked));
+ miWindow.MenuItems.Add("MDI Tabbed", new System.EventHandler(this.TabbedWindows_Clicked));
+ // Let the TabbedMDIManager insert the Mdi Child windows list
+ this.tabbedMDIManager.MdiListMenuItem = miWindow;
+
+ // Append menus to the standard mdi tab context menu
+ ParentBarItem contextMenuItem = new ParentBarItem();
+ BarItem newDocItem = new BarItem();
+ newDocItem.Click += new System.EventHandler(this.addDoc1_Click);
+ newDocItem.Text = "Custom Item: Insert New Doc";
+ newDocItem.MergeOrder = 30;
+ contextMenuItem.Items.Add(newDocItem);
+ BarItem exitItem = new BarItem();
+ exitItem.Click += new System.EventHandler(this.FileExit_Clicked);
+ exitItem.Text = "CustomItem: Exit";
+ exitItem.MergeOrder = 30;
+ contextMenuItem.Items.Add(exitItem);
+ contextMenuItem.BeginGroupAt(newDocItem);
+ // Items in this ParentBarItem will be merged with the standard context menu ParentBarItem of the mdi tab.
+ tabbedMDIManager.ContextMenuItem = contextMenuItem;
+ }
+ // Convenient way to toggle TabbedMDI mode.
+ private bool TabbedMDIOn
+ {
+ get { return this.tabWindowsOn; }
+ set
+ {
+ if(!(this.tabWindowsOn == value))
+ {
+ this.tabWindowsOn = value;
+ if(this.tabWindowsOn)
+ {
+ this.tabbedMDIManager.AttachToMdiContainer(this);
+ }
+ else
+ {
+ this.tabbedMDIManager.DetachFromMdiContainer(this, false); // false to not invoke the Cascade mode after detaching.
+ }
+ }
+ }
+ }
+ //Add a document
+ private void AddDocument(Form doc) {
+ doc.MdiParent = this;
+ doc.Show();
+ }
+ private void MainForm_Load(object sender, System.EventArgs e)
+ {
+ // Add 4 documents
+ this.addDoc1_Click(this, EventArgs.Empty);
+ this.addDoc1_Click(this, EventArgs.Empty);
+ this.addDoc1_Click(this, EventArgs.Empty);
+ this.addDoc1_Click(this, EventArgs.Empty);
+ // Turn on MDI Tabbed Documents mode.
+ // Call this after loading the mdi children to restore their previous state.
+ this.TabbedMDIOn = true;
+ }
+ private int document1Count = 0 ;
+ private void addDoc1_Click(object sender, System.EventArgs e)
+ {
+ document1Count++ ;
+ Document1 doc = new Document1("DocumentOne " + document1Count.ToString());
+ AddDocument(doc);
+ }
+ //Window->Cascade Menu item handler
+ protected void WindowCascade_Clicked(object sender, System.EventArgs e) {
+ this.TabbedMDIOn = false;
+ this.LayoutMdi(MdiLayout.Cascade);
+ }
+ Public Sub New()
+ MyBase.New()
+ '
+ ' Required for Windows Form Designer support
+ '
+ InitializeComponent()
+ tabbedMDIManager = New TabbedMDIManager()
+ 'tabbedMDIManager.UseIconsInTabs = false;
+ 'Add Window Menu
+ Me.miWindow = mainMenu.MenuItems.Add("Window")
+ miWindow.MergeOrder = 10
+ miWindow.MenuItems.Add("Cascade", New System.EventHandler(AddressOf WindowCascade_Clicked))
+ miWindow.MenuItems.Add("Tile Horizontal", New System.EventHandler(AddressOf WindowTileH_Clicked))
+ miWindow.MenuItems.Add("Tile Vertical", New System.EventHandler(AddressOf WindowTileV_Clicked))
+ miWindow.MenuItems.Add("MDI Tabbed", New System.EventHandler(AddressOf TabbedWindows_Clicked))
+
+ ' Let the TabbedMDIManager insert the Mdi Child windows list
+ Me.tabbedMDIManager.MdiListMenuItem = miWindow
+
+ ' Append menus to the standard mdi tab context menu
+ Dim contextMenuItem As ParentBarItem
+ contextMenuItem = New ParentBarItem()
+ Dim newDocItem As BarItem
+ newDocItem = New BarItem()
+ AddHandler newDocItem.Click, New System.EventHandler(AddressOf addDoc1_Click)
+ newDocItem.Text = "Custom Item: Insert New Doc"
+ newDocItem.MergeOrder = 30
+ contextMenuItem.Items.Add(newDocItem)
+ Dim exitItem As BarItem
+ exitItem = New BarItem()
+ AddHandler exitItem.Click, New System.EventHandler(AddressOf FileExit_Clicked)
+ exitItem.Text = "CustomItem: Exit"
+ exitItem.MergeOrder = 30
+ contextMenuItem.Items.Add(exitItem)
+ contextMenuItem.BeginGroupAt(newDocItem)
+ ' Items in this ParentBarItem will be merged with the standard context menu ParentBarItem of the mdi tab.
+ tabbedMDIManager.ContextMenuItem = contextMenuItem
+ End Sub
+ ' Convenient way to toggle TabbedMDI mode.
+ Property TabbedMDIOn() As Boolean
+ Get
+ Return Me.tabWindowsOn
+ End Get
+ Set(ByVal Value As Boolean)
+ If (Not (Me.tabWindowsOn = Value)) Then
+ Me.tabWindowsOn = Value
+ If Me.tabWindowsOn Then
+ Me.tabbedMDIManager.AttachToMdiContainer(Me)
+ Else
+ Me.tabbedMDIManager.DetachFromMdiContainer(Me, False)
+ End If
+ End If
+ End Set
+ End Property
+ Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
+ MyBase.Dispose(disposing)
+ If (Not (components) Is Nothing) Then
+ components.Dispose()
+ End If
+ End Sub
+ Private Sub AddDocument(ByVal doc As Form)
+ doc.MdiParent = Me
+ doc.Show()
+ End Sub
+ Private Sub MainForm_Load(ByVal sender As Object, ByVal e As EventArgs)
+ ' Add 4 documents
+ Me.addDoc1_Click(Me, EventArgs.Empty)
+ Me.addDoc1_Click(Me, EventArgs.Empty)
+ Me.addDoc1_Click(Me, EventArgs.Empty)
+ Me.addDoc1_Click(Me, EventArgs.Empty)
+ ' Turn on MDI Tabbed Documents mode.
+ ' Call this after loading the mdi children to restore their previous state.
+ Me.TabbedMDIOn = True
+ End Sub
+ Private Sub addDoc1_Click(ByVal sender As Object, ByVal e As EventArgs)
+ document1Count = (document1Count + 1)
+ Dim doc As Document1
+ doc = New Document1(("DocumentOne " + document1Count.ToString))
+ AddDocument(doc)
+ End Sub
+ ' Window->Cascade Menu item handler
+ Protected Sub WindowCascade_Clicked(ByVal sender As Object, ByVal e As EventArgs)
+ Me.TabbedMDIOn = False
+ Me.LayoutMdi(MdiLayout.Cascade)
+ End SubIf a child form's ControlBox property is set to false, then the control box buttons will be drawn + inactive rather than hidden, in accordance with the .NET menus behavior.
+If you want to alter this behavior and instead want the control box to be hidden, set this property + to false.
+
+ public void InitMyFileMenu()
+ {
+ // Set the MergeType to Add so that the bar item is added to the
+ // merged menu/bar.
+ barItem1.MergeType = MenuMerge.Add;
+ // Set the MergeOrder to 1 so that this bar item is placed lower
+ // in the merged menu/bar order.
+ barItem1.MergeOrder = 1;
+ }
+
+
+ public void Popup(Object sender, EventArgs e)
+ {
+ // Determine if there is text selected in textBox1.
+ if(textBox1.SelectedText == "")
+ {
+ // Disable the menus since no text is selected in textBox1.
+ menuItemCut.Enabled = false;
+ menuItemCopy.Enabled = false;
+ menuItemDelete.Enabled = false;
+ }
+ else
+ {
+ // Text is selected in textBox1, so enable menu items.
+ menuItemCut.Enabled = true;
+ menuItemCopy.Enabled = true;
+ menuItemDelete.Enabled = true;
+ }
+ }
+
+
+ // The following event handler would be connected to three menu items.
+ private void MyMenuClick(Object sender, EventArgs e)
+ {
+ // Determine if clicked menu item is the Blue bar item.
+ if(sender == menuItemBlue)
+ {
+ // Set the checkmark for the menuItemBlue bar item.
+ menuItemBlue.Checked = true;
+ // Uncheck the menuItemRed and menuItemGreen bar items.
+ menuItemRed.Checked = false;
+ menuItemGreen.Checked = false;
+ // Set the color of the text in the TextBox control to Blue.
+ textBox1.ForeColor = Color.Blue;
+ }
+ else if(sender == menuItemRed)
+ {
+ // Set the checkmark for the menuItemRed bar item.
+ menuItemRed.Checked = true;
+ // Uncheck the menuItemBlue and menuItemGreen bar items.
+ menuItemBlue.Checked = false;
+ menuItemGreen.Checked = false;
+ // Set the color of the text in the TextBox control to Red.
+ textBox1.ForeColor = Color.Red;
+ }
+ else
+ {
+ // Set the checkmark for the menuItemGreen.
+ menuItemGreen.Checked = true;
+ // Uncheck the menuItemRed and menuItemBlue bar items.
+ menuItemBlue.Checked = false;
+ menuItemRed.Checked = false;
+ // Set the color of the text in the TextBox control to Blue.
+ textBox1.ForeColor = Color.Green;
+ }
+ }
+
+
+ public void SetupMyMenuItem()
+ {
+ // Set the caption for the bar item.
+ barItem1.Text = "New";
+ // Assign a shortcut key.
+ barItem1.Shortcut = Shortcut.CtrlN;
+ // Make the bar item visible.
+ barItem1.Visible = true;
+ }
+
+
+ public void SetupMyMenuItem()
+ {
+ // Set the caption for the bar item.
+ barItem1.Text = "New";
+ // Assign a shortcut key.
+ barItem1.Shortcut = Shortcut.CtrlN;
+ // Make the bar item visible.
+ barItem1.Visible = true;
+ }
+
+
+ Public Sub SetupMyMenuItem()
+ ' Set the caption for the bar item.
+ barItem1.Text = "New"
+ ' Assign a shortcut key.
+ barItem1.Shortcut = Shortcut.CtrlN
+ ' Make the bar item visible.
+ barItem1.Visible = True
+ End Sub 'SetupMyMenuItem
+
+
+ public void SetupMyMenuItem()
+ {
+ // Set the caption for the menu item.
+ menuItem1.Text = "New";
+ // Assign a shortcut key.
+ menuItem1.Shortcut = Shortcut.CtrlN;
+ // Make the menu item visible.
+ menuItem1.Visible = true;
+ }
+
+
+ Public Sub SetupMyMenuItem()
+ ' Set the caption for the menu item.
+ menuItem1.Text = "New"
+ ' Assign a shortcut key.
+ menuItem1.Shortcut = Shortcut.CtrlN
+ ' Make the menu item visible.
+ menuItem1.Visible = True
+ End Sub 'SetupMyMenuItem
+
+ To reset this property programmatically, specify null. In design time select "Reset" + from the context menu of the property grid entry of this property.
+This property is useful when you want to replace the default + shortcut text (for example, "Ctrl+D0", displayed when Shortcut.Ctrl0 is the shortcut), + with something else (say "Ctrl0", in the above example). +
+
+ private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
+ {
+ if(e.Button != MouseButtons.Right)
+ return;
+
+ PopupMenu popup = new PopupMenu();
+ ParentBarItem parentItem = new ParentBarItem();
+
+ barItem1.Checked = true;
+ barItem1.Click += new EventHandler(ItemClicked);
+ barItem2.Click += new EventHandler(ItemClicked);
+
+ barItem3.Click += new EventHandler(ItemClicked);
+
+ parentItem.Items.Add(barItem1);
+ parentItem.Items.Add(barItem2);
+ parentItem.Items.Add(barItem3);
+
+ popup.ParentBarItem = parentItem;
+ popup.Show(this, new Point(e.X, e.Y));
+ }
+
+
+ private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
+ {
+ PopupMenu popup = new PopupMenu();
+ ParentBarItem parentItem = new ParentBarItem();
+ parentItem.CloseOnClick = false;
+
+ barItem1.Checked = true;
+ barItem1.Click += new EventHandler(ItemClicked);
+ barItem2.Checked = true;
+ barItem2.Click += new EventHandler(ItemClicked);
+
+ barItem3.Checked = true;
+ barItem3.Click += new EventHandler(ItemClicked);
+
+ parentItem.Items.Add(barItem1);
+ parentItem.Items.Add(barItem2);
+ parentItem.Items.Add(barItem3);
+
+ popup.ParentBarItem = parentItem;
+ popup.Show(this, new Point(e.X, e.Y));
+ }
+ private void ItemClicked(object sender, EventArgs e)
+ {
+ BarItem itemClicked = sender as BarItem;
+ itemClicked.Checked = !itemClicked.Checked;
+ }
+
+
+ Use this method in the context of "Automatic MDI Merging" (see
+ // Listen to the AfterClone event of the ChildFrameBarManager and
+ // set the cloned BarManager's ImageList and LargeImageList.
+ // This is necessary because cloning an ImageList (il1.ImageStream = il2.ImageStream;) seems to be broken in 1.1.
+ private void childFrameBarManager_AfterClone(object sender, Syncfusion.Windows.Forms.Tools.XPMenus.BarManagerClonedEventArgs args)
+ {
+ System.Resources.ResourceManager resources = new System.Resources.ResourceManager(this.GetType());
+
+ // Load the images from the resource and set it to the ImageLists.
+ // You can typically copy the right-hand side portion of the following statements from the
+ // designer generated code in the InitializeComponent method.
+ // imgList16 and imgList24 are the names of the ImageList instances in this Form.
+ args.ClonedBarManager.ImageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imgList16.ImageStream")));
+ args.ClonedBarManager.LargeImageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imgList24.ImageStream")));
+ }
+
+
+ ' Listen to the AfterClone event of the ChildFrameBarManager and
+ ' set the cloned BarManager's ImageList and LargeImageList.
+ ' This is necessary because cloning an ImageList (il1.ImageStream = il2.ImageStream;) seems to be broken in 1.1.
+ Private Sub childFrameBarManager_AfterClone(ByVal sender As Object, ByVal args As Syncfusion.Windows.Forms.Tools.XPMenus.BarManagerClonedEventArgs)
+ Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(Me.GetType())
+
+ ' Load the images from the resource and set it to the ImageLists.
+ ' You can typically copy the right-hand side portion of the following statements from the
+ ' designer generated code in the InitializeComponent method.
+ args.ClonedBarManager.ImageList.ImageStream = (CType((resources.GetObject("imgList16.ImageStream")), System.Windows.Forms.ImageListStreamer))
+ args.ClonedBarManager.LargeImageList.ImageStream = (CType((resources.GetObject("imgList24.ImageStream")), System.Windows.Forms.ImageListStreamer))
+ End Sub
+
+ This is usually called for a
+ This event is provided to workaround a 1.1 framework bug which prevents us from cloning an + ImageList (The code "imageList.ImageStream = anotherImageList.ImageStream" doesn't work in 1.1). +
+
+ this.popupMenusManager1.SetXPContextMenu(this.richTextBox1, this.popupMenu2);
+
+
+ Me.popupMenusManager1.SetXPContextMenu(Me.richTextBox1, Me.popupMenu2)
+
+
+ // Create and initialize a ParentBarItem
+ this.editBarItem = new Syncfusion.Windows.Forms.Tools.ParentBarItem();
+ this.editMenu.Text = "Edit";
+ this.editMenu.Items.AddRange(new BarItem[]
+ { this.cutItem,
+ this.copyItem,});
+ // Associate the ParentBarItem with the PopupMenu
+ this.popupMenu1 = new Syncfusion.Windows.Forms.Tools.PopupMenu();
+ this.popupMenu1.ParentBarItem = this. editBarItem;
+
+ // Then associate it with a RichTextBox
+ this.popupMenusManager = new PopupMenusManager();
+ this.popupMenusManager.SetXPContextMenu(this.richTextBox1, this.popupMenu1);
+
+
+ ' Create and initialize a ParentBarItem
+ Me.editBarItem = New Syncfusion.Windows.Forms.Tools.ParentBarItem()
+ Me.editMenu.Text = "Edit"
+ Me.editMenu.Items.AddRange(New BarItem() {Me.cutItem, Me.copyItem})
+
+ ' Associate the ParentBarItem with the PopupMenu
+ Me.popupMenu1 = New Syncfusion.Windows.Forms.Tools.PopupMenu()
+ Me.popupMenu1.ParentBarItem = Me.editBarItem
+
+ ' Then associate it with a RichTextBox
+ Me.popupMenusManager = New PopupMenusManager()
+ Me.popupMenusManager.SetXPContextMenu(Me.richTextBox1, Me.popupMenu1)
+
+ 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. +
+
+ In code, you can initialize an XPToolBar as follows:
+ XPToolBar xpToolBar1;
+ // Create a new tool bar control.
+
+ XPToolBar xptoolbar2 = new XPToolBar();
+ // Add some one or more instances of BarItem to it.
+ xptoolbar2.Items.AddRange(new BarItem[]{this.barItem1, this.barItem2, this.barItem3});
+ // Setup a separator.
+ xptoolbar2.BeginGroupAt(this.barItem2);
+
+ // Set its position and add it to the Form.
+ xptoolbar2.Dock = DockStyle.Top;
+ xptoolbar2.Size = new Size(200, 30);
+ this.Controls.Add(xptoolbar2);
+
+
+ Dim xpToolBar1 As XPToolBar
+ ' Create a new tool bar control.
+ Dim xptoolbar2 As New XPToolBar()
+
+ ' Add some one or more instances of BarItem to it.
+ xptoolbar2.Items.AddRange(New BarItem() {Me.barItem1, Me.barItem2, Me.barItem3})
+ ' Setup a separator.
+ xptoolbar2.BeginGroupAt(Me.barItem2)
+
+ ' Set its position and add it to the Form.
+ xptoolbar2.Dock = DockStyle.Top
+ xptoolbar2.Size = New Size(200, 30)
+ Me.Controls.Add(xptoolbar2)
+
+
+ private void Form_Load(object sender, System.EventArgs e)
+ {
+ this.barControl1.Items.Add(this.barItem1);
+ this.barControl1.Items.Add(this.barItem2);
+ this.barControl1.Items.Add(this.parentBarItem1);
+ }
+
+
+ this.ribbonControlAdv1.ThemeStyle.FileMenuForeColor = Color.Yellow;
+
+
+ this.ribbonControlAdv1.ThemeStyle.FileMenuBackColor = Color.Yellow;
+
+
+ this.ribbonControlAdv1.ThemeStyle.FileMenuHoverBackColor = Color.Yellow;
+
+