Add CheckBox to GroupBox header

Hi @all,

i would like to add an Eto.Forms.CheckBox to the Header of an Eto.Forms.GroupBox but have no idea how to do it. The purpose is that the CheckBox then enables/disables some content of the GroupBox. Is it possible with Eto any Python ?

thank you,
c.

How about something like this?

image

– Dale

Hi @dale, that is close…

is yours a CheckBox followed by a Rhino.UI.Controls.LabelSeparator ?

thanks,
c.

Hi @clement,

The panel uses an Eto.Forms.CheckBox and a Rhino.UI.Controls.Divider.

I’ll let you do the Python port.

class CheckBoxSeparator : Panel
{
  /// <summary>
  /// Public constructor
  /// </summary>
  public CheckBoxSeparator()
  {
    CheckBox = new CheckBox();
    m_divider = new Divider();

    Content = new StackLayout
    {
      Orientation = Orientation.Horizontal,
      VerticalContentAlignment = VerticalAlignment.Stretch,
      Spacing = 2,
      Items =
      {
        CheckBox,
        new StackLayoutItem(m_divider, true)
      }
    };
  }

  // The divider or separator
  readonly Divider m_divider;

  /// <summary>
  /// Gets the checkbox
  /// </summary>
  public CheckBox CheckBox { get; }

  /// <summary>
  /// Gets or sets the text of the checkbox
  /// </summary>
  public string Text
  {
    get => CheckBox.Text;
    set => CheckBox.Text = value;
  }

  /// <summary>
  /// Gets or sets the color of the line separator
  /// </summary>
  public Color Color
  {
    get => m_divider.Color;
    set => m_divider.Color = value;
  }
}

– Dale

1 Like

Hi @dale, thank you. That is a possible workaround but i still would like to know if it is doable with a GroupBox header. I managed to access the header of a GroupBox and it kind of “accepts” a CheckBox like this:

 self.m_checkbox = Eto.Forms.CheckBox(Text="MyCheckBoxText", Checked=True)
 self.m_groupbox = Eto.Forms.GroupBox(Text="MyGroupBoxText")
 self.m_groupbox.ControlObject.Header = self.m_checkbox

grafik

but it doesn’t show the CheckBox instead of the header (label), instead it justs writes out “Eto.Forms.CheckBox”. There seems to be a way with wpf but i have no clue how to do the same in pyhon.

_
c.

Try this instead:

self.m_groupbox.ControlObject.Header = self.m_checkbox.ControlObject

Do note this means it will only work on Windows.

1 Like

Hi @curtisw, i’m attaching the sample script here, it gives me an error and asks to first perform some kind of pre-division…

SampleGroupBox.py (1.7 KB)

This would be OK once it works.

thanks,
c.

Ah yes, this should work instead.

self.m_groupbox.ControlObject.Header = self.m_checkbox.Handler.ContainerControl
1 Like

Thank you @curtisw and @dale, it works!

grafik
_
c.