public CtrlInfo(CtlBinder <T> owner, Control control, PropertyPath <T, object> path, Binder binder) { this.Owner = owner; this.Control = control; this.Path = path; this.Binder = binder; }
public TableLayoutPanel AutoBind(params PropertyPath <T, object>[] properties) { TableLayoutPanel container = new TableLayoutPanel() { Visible = true, Dock = DockStyle.Top, AutoSize = true, AutoSizeMode = AutoSizeMode.GrowAndShrink, }; container.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 100.0f)); container.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100.0f)); container.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 100.0f)); for (int n = 0; n < properties.Length; n++) { PropertyPath <T, object> path = properties[n]; Type type = path.Last.PropertyType; Binder binder = this.BinderCollection.FindSuitableBinderOrNull(type); if (binder == null) { // Ignore since we are AUTO binding continue; } Label label = new Label() { Text = GetPropertyName(path), Visible = true, AutoSize = true, }; container.RowStyles.Add(new RowStyle(SizeType.AutoSize, 100.0f)); container.Controls.Add(label, 0, n); Control control = binder.CreateControl(type); control.Visible = true; container.Controls.Add(control, 1, n); Bind(control, path); } return(container); }