GrapeCity MultiRow Windows Forms Documentation
Hiding Spin Button (NumericUpDownCell)

You can hide the spin button in the numeric up down cell by setting the NumericUpDownCell.ShowSpinButton property to NotShown; however, this setting is only enabled when the cell is not in an editable state. In order to hide the spin button in an editable state, you need to adjust the position of the spin button so that it is not visible when the numeric up down cell displays the cell editing control.

Using Code

The following code creates a user-defined numeric cell that inherits from the NumericUpDownCell class.

[VB]

Imports System.Drawing
Imports System.Windows.Forms
Imports GrapeCity.Win.MultiRow

' NumericUpDownCell without the spin button.
 NumericUpDownCell
 Public Class NumericCell
    Inherits NumericUpDownCell

    Public Sub New()
        Me.ShowSpinButton = CellButtonVisibility.NotShown
    End Sub

    Protected Overrides Function GetEditingControlBounds(ByVal cellBounds As System.Drawing.Rectangle, ByVal rowIndex As Integer) As System.Drawing.Rectangle
        Return New Rectangle(cellBounds.Location, New Size(cellBounds.Width + SystemInformation.VerticalScrollBarWidth, cellBounds.Height))
    End Function
End Class

[CS]

using System.Drawing;
using System.Windows.Forms;
using GrapeCity.Win.MultiRow;

// NumericUpDownCell without the spin button.
public class NumericCell : NumericUpDownCell
{
    public NumericCell()
    {
        this.ShowSpinButton = CellButtonVisibility.NotShown;
    }

    protected override Rectangle GetEditingControlBounds(Rectangle cellBounds, int rowIndex)
    {
        return new Rectangle(cellBounds.Location, new Size(cellBounds.Width + SystemInformation.VerticalScrollBarWidth, cellBounds.Height));
    }
}

Using the Designer

Use the following steps to use the custom NumericCell in the designer.

  1. Save the above code in a file such as NumericCell.vb or NumericCell.cs.
  2. Add the file to a project.
  3. Build the project.
  4. Open the template designer.
  5. Select "NumericCell" from the toolbar and place it on the designer by dragging it.

Using Code

This example uses the custom cell.

[VB]

Imports GrapeCity.Win.MultiRow

Dim numericCell1 As New NumericCell()

GcMultiRow1.Template = Template.CreateGridTemplate(New Cell() { numericCell1 })
GcMultiRow1.RowCount = 10

[CS]

using GrapeCity.Win.MultiRow;

NumericCell numericCell1 = new NumericCell();

gcMultiRow1.Template = Template.CreateGridTemplate(new Cell[] { numericCell1 });
gcMultiRow1.RowCount = 10;
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options