How to set the OnText/OffText of a GridSwitchButtonEditControl of a SuperGridControl column?

401 views Asked by At

I'm using this grid control on my project, and i want to be able to edit the ON OFF text of an entire column that has a GridSwitchButtonEditControl editortype.

The documentation of the component is over here

But i can't figure out how to set the default properties of the editor control of an entire column, nor the properties of a single row column editor (which according to the documentation are inherited from the column's editorcontrol).

Can someone please help me?

Thank's in advance

2

There are 2 answers

0
Bmt On

Here is one simple way:

    SetSwitchText(column.EditControl as GridSwitchButtonEditControl);
    SetSwitchText(column.RenderControl as GridSwitchButtonEditControl);

    private void SetSwitchText(GridSwitchButtonEditControl ctl)
    {
        if (ctl != null)
        {
            ctl.OnText = "Yea";
            ctl.OffText = "Nay";
        }
    }
0
gersis On
  1. create your own GridSwitchButtonEditControl class with custom values

    Private Class MyGridSwitchButtonEditControl Inherits GridSwitchButtonEditControl Public Sub New() StretchBehavior = StretchBehavior.HorizontalOnly OnText = "HELLO" OffText = "BYE" End Sub End Class

  2. Create a sub to initialize the grid with your own Editor

    Private Sub InitializeGrid() Dim pnl = supergridcontrol1.PrimaryGrid Dim column As GridColumn = pnl.Columns("Column6") column.EditorType = GetType(MyGridSwitchButtonEditControl) End Sub

'3. On form Load call the InitializeGrid() to teach the grid on use your customized editor

Private Sub Fmain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
InitializeGrid()
End sub

This way your grid is initialized with your customized Editor. You can now see that OnText is "HELLO" and OffText is "BYE". Note that "Column6" is the name of the column where Editor is consumed (you can also use index)

Hope this helps

Greetings from Italy :)