Hello Rhino developers, lately I have been working more with Eto forms, and I am trying to understand more its layout, how to control it or how to define which parts to be resized. (with c#)
for example, I have a form that includes a line for text and a select button right next to it. and the next line includes a gridview table. when I resize the panel, the select button gets bigger while the gridview table size doesn’t change.
How can I control the resizing parts (left side? right side of the panel?)
Using a TableLayout you can specify which cell expands through the TableCell ScaleWidth boolean.
TableCell(control ctl, bool scaleWidth)
var table_button = new TableLayout() { Spacing = new Size(8, 8)};
table_button.Rows.Add(new TableRow(new TableCell(label,true),new TableCell(button)));
thank you for replying! using new TableCell(GridView,true) helped me to fit the size of the gridview to the resizable panel. but at the same time, the textbox is changing.
how can I change only the gridview, and keep the textbox and the select button static?
I tried this to add the same thing with false: new TableCell(TextBox,false) but it didn’t work.
The Tables are made up of Rows and Columns. Currently you have 2 rows and and 2 columns.
The label and the gridview are in column 1 while the button is in column 2.
When using a table layout you can nest additional table layouts since you cant easily span cells. This way you can have a body table with 1 column and multiple rows.
if you want a layout closer to your blue mark up then you can add an additional cell after the button that can be your expander.
Here’s a quick example.
var table_button = new TableLayout() { Spacing = new Size(8, 8) };
table_button.Rows.Add(new TableRow(new TableCell(new TextBox(), true), new TableCell(new Button() { Text = "Select" }),null));
var table_body = new TableLayout() { Spacing = new Size(8, 8) };
table_body.Rows.Add(new TableRow(new TableCell(table_button)));
table_body.Rows.Add(new TableRow(new GridView()) { ScaleHeight = true });
var cmd = new CommandDialog(){Size = new Size(800,600)};
cmd.Resizable = true;
cmd.Content = table_body;
cmd.ShowModal(RhinoEtoApp.MainWindow);
I added more to my example for you. You should get this running my code above. You need to define an additional cell. 3 columns, 1 row for table buttons. The last cell can just be null and eto will make it an expanding blank cell.
a different but related question: the select button works only when the ok button is clicked(first I click select then ok, then it closes the panel and I see the selection)
I need to select from rhino objects, while the panel is opened, and without closing it.
There’s special click handler called PushPickButton that you’ll need that’s located in Rhino.UI.EtoExtensions. Using this will hide the modal dialog temporarily while you select some objects and then return the dialog after the selection.
Here’s an example using the existing code above.
var cmd = new CommandDialog(){Size = new Size(800,600)};
cmd.Resizable = true;
var btn_select = new Button() { Text = "Select" };
btn_select.Click += (sender, args) => cmd.PushPickButton((s, e) =>
{
using (var go = new GetObject())
{
go.SetCommandPrompt("Select something");
go.Get();
var res = go.Result();
}
});
var table_button = new TableLayout() { Spacing = new Size(8, 8) };
table_button.Rows.Add(new TableRow(new TableCell(new TextBox(), true), new TableCell(btn_select),null));
var table_body = new TableLayout() { Spacing = new Size(8, 8) };
table_body.Rows.Add(new TableRow(new TableCell(table_button)));
table_body.Rows.Add(new TableRow(new GridView()) { ScaleHeight = true });
cmd.Content = table_body;
cmd.ShowModal(RhinoEtoApp.MainWindow);