Autor Beitrag
anb
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Mo 26.04.10 14:24 
Hallo,

ich habe folgendes Problem, für das es sicher eine einfache Lösung gibt. Ich möchte, dass sich mit dem Ändern der Fenstergröße meiner Anwendung, die Darstellung im selben Verhältnis mit ändert. Dies habe ich erreicht indem ich als Simple-Bsp. einen Button auf eine tablelayoutpanel lege. Das funktioniert ohne Überraschungen. Zusätzlich hätte ich gern, dass sich auch die Beschriftung auf dem Button mit ändert. Sicher ist es simpel zu lösen und ich habe nur den "Schalter" nicht gefunden. Eigentlich sicher nicht nötig, aber der Simpel-code des Designers um die gewählten Eigenschaften zu sehen (nutze SharpDevelop mit dem 3.5'er framework):

ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
namespace test
{
partial class MainForm
{
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}

/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.button1 = new System.Windows.Forms.Button();
this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tableLayoutPanel1.AutoSize = true;
this.tableLayoutPanel1.ColumnCount = 3;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 37.28814F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 29.37853F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tableLayoutPanel1.Controls.Add(this.button1, 11);
this.tableLayoutPanel1.Location = new System.Drawing.Point(13);
this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 3;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 81.81818F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 18.18182F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 109F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(291269);
this.tableLayoutPanel1.TabIndex = 0;
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.button1.Location = new System.Drawing.Point(111133);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(7923);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
//
// MainForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
this.ClientSize = new System.Drawing.Size(292266);
this.Controls.Add(this.tableLayoutPanel1);
this.Name = "MainForm";
this.Text = "test";
this.tableLayoutPanel1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Button button1;
}
}


Thx

Moderiert von user profile iconKha: C#-Tags hinzugefügt
danielf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1012
Erhaltene Danke: 24

Windows XP
C#, Visual Studio
BeitragVerfasst: Mo 26.04.10 14:32 
Hallo und :welcome:,

also falls es eine solches Property gibt, hab ich es auch immer übersehen - deine Augen sind in Ordnung ;)

Ich befürchte ein solche Funktionalität muss man selbst programmieren. Hierfür denke ich ist das einfachst von Button abzuleiten und bei Resize die Schriftgröße anzupassen. Mit MeasureText kannst du dabei überprüfen ob der Text noch in das Benutzerelement passt.

Gruß
anb Threadstarter
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Mi 28.04.10 21:03 
Hallo Daniel,

vielen Dank für Deine Antwort. Das Leben wär ja auch zu einfach :-) Ich werde es wohl so angehen wie von Dir vorgeschlagen. Also vieln Dank nochmal für die Antwort.


André