# HG changeset patch # User StephaneLenclud # Date 1469632150 -7200 # Node ID 471cb4c8a09ad69124ed9256f2daabc3bb8aa6bf # Parent f6272f65d8fcbc209b3a595d7dceeb8877fe7c24 Make sure action edit combo box for enums is long enough. diff -r f6272f65d8fc -r 471cb4c8a09a Server/FormEditAction.Designer.cs --- a/Server/FormEditAction.Designer.cs Wed Jul 27 15:05:58 2016 +0200 +++ b/Server/FormEditAction.Designer.cs Wed Jul 27 17:09:10 2016 +0200 @@ -39,11 +39,13 @@ // // comboBoxActionType // + this.comboBoxActionType.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.comboBoxActionType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBoxActionType.FormattingEnabled = true; this.comboBoxActionType.Location = new System.Drawing.Point(55, 12); this.comboBoxActionType.Name = "comboBoxActionType"; - this.comboBoxActionType.Size = new System.Drawing.Size(333, 21); + this.comboBoxActionType.Size = new System.Drawing.Size(272, 21); this.comboBoxActionType.Sorted = true; this.comboBoxActionType.TabIndex = 18; this.comboBoxActionType.SelectedIndexChanged += new System.EventHandler(this.comboBoxActionType_SelectedIndexChanged); @@ -86,6 +88,7 @@ | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.iTableLayoutPanel.AutoSize = true; + this.iTableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.iTableLayoutPanel.ColumnCount = 2; this.iTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.iTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); @@ -94,7 +97,7 @@ this.iTableLayoutPanel.RowCount = 2; this.iTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.iTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.iTableLayoutPanel.Size = new System.Drawing.Size(375, 16); + this.iTableLayoutPanel.Size = new System.Drawing.Size(312, 16); this.iTableLayoutPanel.TabIndex = 23; // // FormEditAction @@ -103,8 +106,9 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoSize = true; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(402, 107); + this.ClientSize = new System.Drawing.Size(339, 107); this.Controls.Add(this.iTableLayoutPanel); this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonOk); diff -r f6272f65d8fc -r 471cb4c8a09a Server/FormEditAction.cs --- a/Server/FormEditAction.cs Wed Jul 27 15:05:58 2016 +0200 +++ b/Server/FormEditAction.cs Wed Jul 27 17:09:10 2016 +0200 @@ -136,18 +136,27 @@ { //Enum properties are using combo box ComboBox ctrl = new ComboBox(); - ctrl.AutoSize = true; - ctrl.Sorted = true; + ctrl.AutoSize = true; + ctrl.Sorted = true; ctrl.DropDownStyle = ComboBoxStyle.DropDownList; //Data source is fine but it gives us duplicate entries for duplicated enum values //ctrl.DataSource = Enum.GetValues(aInfo.PropertyType); //Therefore we need to explicitly create our items + Size cbSize = new Size(0,0); foreach (string name in aInfo.PropertyType.GetEnumNames()) { ctrl.Items.Add(name.ToString()); + Graphics g = this.CreateGraphics(); + //Since combobox autosize would not work we need to get measure text ourselves + SizeF size=g.MeasureString(name.ToString(), ctrl.Font); + cbSize.Width = Math.Max(cbSize.Width,(int)size.Width); + cbSize.Height = Math.Max(cbSize.Height, (int)size.Height); } + //Make sure our combobox is large enough + ctrl.MinimumSize = cbSize; + // Instantiate our enum object enumValue = Activator.CreateInstance(aInfo.PropertyType); enumValue = aInfo.GetValue(aAction); @@ -246,6 +255,9 @@ iTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); //Create the label Label label = new Label(); + label.AutoSize = true; + label.Dock = DockStyle.Fill; + label.TextAlign = ContentAlignment.MiddleCenter; label.Text = attribute.Name; toolTip.SetToolTip(label, attribute.Description); iTableLayoutPanel.Controls.Add(label, 0, iTableLayoutPanel.RowCount-1);