Autor Beitrag
IsabelleZimmermann
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54



BeitragVerfasst: Di 15.01.19 17:26 
Hallo zusammen,

ich schreibe eine Anwendersoftware zur Maschinenbedienung. In diesem Fall ein neuer Säge-und Stanzautomat, welcher über 10 Einzelachsen für die Profile und 2 Einzelachsen für die Sägen sowie eine Einzelachse für ein Abdeckteil gesteuert werden soll.

Dazu hab ich in dem "Diagnose-Fenster" ein neues Form für die Servo-Motoren angelegt.
Es ist so, dass abhängig von der Auswahl des jeweiligen Servomotors die Funktion "Start Moving" eines Buttons zum Beispiel andere Zielpositionen und Geschwindigkeiten besitzen. Eventuell ist die Funktion für "Enable" auch unterschiedlich, das weiß ich aber nicht genau.

Meine Frage ist jetzt, wie ich die Labels und Buttons für alle ausgewählten Motoren gleich gestalte, aber die Funktionalität hinter den Buttons sich ändert.

Sorry, aber steh gerade auf der Leitung. Deshalb bin ich wahrscheinlich noch nicht auf die Lösung gekommen...

Viele Grüße,
Isabelle

Hier mein Code:
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:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
public class Form1 : Form
{
       
 private ToolStrip toolStrip1;
 private ToolStripComboBox toolStripComboBox1;

 public Form1()
 {
    Label lbl_ServoMotoren = new Label();
    lbl_ServoMotoren.Text = "Servo-Motoren";
    lbl_ServoMotoren.Size = new Size(15020);
    lbl_ServoMotoren.Location = new Point(1000240);
    this.Controls.Add(lbl_ServoMotoren);
    lbl_ServoMotoren.Click += new EventHandler(ServoMotoren_Einblenden);
 }
  void ServoMotoren_Einblenden(object sender, EventArgs e)
  {
    Label InitServo1Achse1, FahrenPosServo1Achse1, SendeDaten, Enable_Servo1Achse1, SoftStop_Servo1Achse1, HardStop_Servo1Achse1, StartMov_Servo1Achse1, ClearWarning_Servo1Achse1, ClearAlarm_Servo1Achse1, PositionEingabe_Servo1Achse1, GeschwindigkeitEingabe_Servo1Achse1;

    Label EmpfangeneDaten, HomingDone_Servo1Achse1, TargetPosition_Servo1Achse1, WarningPresent_Servo1Achse1, AlarmPresent_Servo1Achse1, AktPosition_Servo1Achse1, WarnCode_Servo1Achse1, AlarmCode_Servo1Achse1;

   Button btnInitServo1Achse1, btnFahrenPosServo1Achse1, btnEnableServo1Achse1, btnSoftStopServo1Achse1, btnHardStopServo1Achse1, btnStartMovServo1Achse1, btnClearWarningServo1Achse1, btnClearAlarmServo1Achse1;

   Button btnHomingDoneServo1Achse1, btnTargetPositionServo1Achse1, btnWarningServo1Achse1, btnAlarmServo1Achse1;
   
   TextBox tbxPosEingabe_Servo1Achse1, tbxGeschwEingabe_Servo1Achse1, tbxAktPosBerechnung_Servo1Achse1, tbxWarnCodeAnzeige_Servo1Achse1, tbxAlarmCodeAnzeige_Servo1Achse1;

    // Funktionalitäten für Servomotor einblenden
    toolStrip1 = new System.Windows.Forms.ToolStrip();
    toolStripComboBox1 = new System.Windows.Forms.ToolStripComboBox();
    toolStrip1.SuspendLayout();
    SuspendLayout();
   // 
   // toolStrip1
  // 
  toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
  toolStripComboBox1});
  toolStrip1.Location = new System.Drawing.Point(1200150);
  toolStrip1.Name = "Servomotor-Auswahl";
  toolStrip1.Size = new System.Drawing.Size(14025);
  toolStrip1.TabIndex = 0;
  toolStrip1.Text = "toolStrip1";
  // The following code demonstrates the syntax for setting
 // various ToolStripComboBox properties.
 // 
  toolStripComboBox1.AutoCompleteCustomSource.AddRange(new string[] {
            "Servo1 - Achse1",
            "Servo2 - Achse2",
            "Servo3 - Achse3",
            "Servo4 - Achse4",
            "Servo5 - Achse5",
            "Servo6 - Achse6",
            "Servo7 - Achse7",
            "Servo8 - Achse8",
            "Servo9 - Achse9",
            "Servo10 -Achse10",
            "Servo1 - AchseSäge1",
            "Servo2 - AchseSäge2",
            "Servo3 - AchseAbdeckkeder1" });
                toolStripComboBox1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
                toolStripComboBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;
                toolStripComboBox1.DropDownHeight = 110;
                toolStripComboBox1.DropDownWidth = 122;
                toolStripComboBox1.FlatStyle = System.Windows.Forms.FlatStyle.Standard;
                toolStripComboBox1.IntegralHeight = false;
                toolStripComboBox1.Items.AddRange(new object[] {
            "Servo1 - Achse1",
            "Servo2 - Achse2",
            "Servo3 - Achse3",
            "Servo4 - Achse4",
            "Servo5 - Achse5",
            "Servo6 - Achse6",
            "Servo7 - Achse7",
            "Servo8 - Achse8",
            "Servo9 - Achse9",
            "Servo10 - Achse10",
            "Servo1 - AchseSäge1",
            "Servo2 - AchseSäge2",
            "Servo3 - AchseAbdeckkeder1" });
                toolStripComboBox1.MaxDropDownItems = 9;
                toolStripComboBox1.MergeAction = System.Windows.Forms.MergeAction.Insert;
                toolStripComboBox1.Name = "toolStripComboBox1";
                toolStripComboBox1.Size = new System.Drawing.Size(12125);
                toolStripComboBox1.Sorted = true;
                // Tschechisch vorgewählt.
                toolStripComboBox1.SelectedIndex = 0;
                Servomotor = toolStripComboBox1.SelectedItem.ToString();
               

                toolStripComboBox1.SelectedIndexChanged += new EventHandler(toolStripComboBox1_selectedIndexServoMotorChanged);

                this.Controls.Add(toolStrip1);
                toolStrip1.ResumeLayout(false);
                toolStrip1.PerformLayout();

                InitServo1Achse1 = new Label();
                InitServo1Achse1.Location = new Point(1200200);
                InitServo1Achse1.Name = "Initialisierung Servo";
                InitServo1Achse1.Size = new Size(6020);
                InitServo1Achse1.Text = "Init Servo";
                this.Controls.Add(InitServo1Achse1);
               

                btnInitServo1Achse1 = new Button();
                btnInitServo1Achse1.Location = new Point(1270200);
                btnInitServo1Achse1.Name = "Button Init Servo1Achse1";
                btnInitServo1Achse1.Size = new Size(2020);
                btnInitServo1Achse1.Text = "";
                this.Controls.Add(btnInitServo1Achse1);
                btnInitServo1Achse1.Click += new EventHandler(btn_InitServo1Achse1_Click);

                FahrenPosServo1Achse1 = new Label();
                FahrenPosServo1Achse1.Location = new Point(1300200);
                FahrenPosServo1Achse1.Name = "Fahren auf Pos";
                FahrenPosServo1Achse1.Size = new Size(8020);
                FahrenPosServo1Achse1.Text = "Fahren auf Pos";
                this.Controls.Add(FahrenPosServo1Achse1);


                btnFahrenPosServo1Achse1 = new Button();
                btnFahrenPosServo1Achse1.Location = new Point(1390200);
                btnFahrenPosServo1Achse1.Name = "Button FahrenPos Servo1Achse1";
                btnFahrenPosServo1Achse1.Size = new Size(2020);
                btnFahrenPosServo1Achse1.Text = "";
                this.Controls.Add(btnFahrenPosServo1Achse1);
                btnFahrenPosServo1Achse1.Click += new EventHandler(btn_FahrenPosServo1Achse1_Click);

                SendeDaten = new Label();
                SendeDaten.Location = new Point(1200250);
                SendeDaten.Name = "Daten senden";
                SendeDaten.Size = new Size(8020);
                SendeDaten.Text = "Sende Daten";
                this.Controls.Add(SendeDaten);

                Enable_Servo1Achse1 = new Label();
                Enable_Servo1Achse1.Location = new Point(1200280);
                Enable_Servo1Achse1.Name = "Enable Servo1Achse1";
                Enable_Servo1Achse1.Size = new Size(8020);
                Enable_Servo1Achse1.Text = "Enable";
                this.Controls.Add(Enable_Servo1Achse1);

                btnEnableServo1Achse1 = new Button();
                btnEnableServo1Achse1.Location = new Point(1290280);
                btnEnableServo1Achse1.Name = "Button Enable Servo1Achse1";
                btnEnableServo1Achse1.Size = new Size(2020);
                btnEnableServo1Achse1.Text = "";
                this.Controls.Add(btnEnableServo1Achse1);
                btnEnableServo1Achse1.Click += new EventHandler(btn_EnableServo1Achse1_Click);

                SoftStop_Servo1Achse1 = new Label();
                SoftStop_Servo1Achse1.Location = new Point(1200310);
                SoftStop_Servo1Achse1.Name = "SoftStop Servo1Achse1";
                SoftStop_Servo1Achse1.Size = new Size(8020);
                SoftStop_Servo1Achse1.Text = "Soft Stop (F)";
                this.Controls.Add(SoftStop_Servo1Achse1);

                btnSoftStopServo1Achse1 = new Button();
                btnSoftStopServo1Achse1.Location = new Point(1290310);
                btnSoftStopServo1Achse1.Name = "Button SoftStop Servo1Achse1";
                btnSoftStopServo1Achse1.Size = new Size(2020);
                btnSoftStopServo1Achse1.Text = "";
                this.Controls.Add(btnSoftStopServo1Achse1);
                btnSoftStopServo1Achse1.Click += new EventHandler(btn_SoftStopServo1Achse1_Click);

                HardStop_Servo1Achse1 = new Label();
                HardStop_Servo1Achse1.Location = new Point(1200340);
                HardStop_Servo1Achse1.Name = "HardStop Servo1Achse1";
                HardStop_Servo1Achse1.Size = new Size(8020);
                HardStop_Servo1Achse1.Text = "Hard Stop (F)";
                this.Controls.Add(HardStop_Servo1Achse1);

                btnHardStopServo1Achse1 = new Button();
                btnHardStopServo1Achse1.Location = new Point(1290340);
                btnHardStopServo1Achse1.Name = "Button HardStop Servo1Achse1";
                btnHardStopServo1Achse1.Size = new Size(2020);
                btnHardStopServo1Achse1.Text = "";
                this.Controls.Add(btnHardStopServo1Achse1);
                btnHardStopServo1Achse1.Click += new EventHandler(btn_HardStopServo1Achse1_Click);

                StartMov_Servo1Achse1 = new Label();
                StartMov_Servo1Achse1.Location = new Point(1320280);
                StartMov_Servo1Achse1.Name = "StartMoving Servo1Achse1";
                StartMov_Servo1Achse1.Size = new Size(6020);
                StartMov_Servo1Achse1.Text = "Start Mov";
                this.Controls.Add(StartMov_Servo1Achse1);

                btnStartMovServo1Achse1 = new Button();
                btnStartMovServo1Achse1.Location = new Point(1390280);
                btnStartMovServo1Achse1.Name = "Button StartMoving Servo1Achse1";
                btnStartMovServo1Achse1.Size = new Size(2020);
                btnStartMovServo1Achse1.Text = "";
                this.Controls.Add(btnStartMovServo1Achse1);
                btnStartMovServo1Achse1.Click += new EventHandler(btn_StartMovServo1Achse1_Click);

                ClearWarning_Servo1Achse1 = new Label();
                ClearWarning_Servo1Achse1.Location = new Point(1320310);
                ClearWarning_Servo1Achse1.Name = "ClearWarning Servo1Achse1";
                ClearWarning_Servo1Achse1.Size = new Size(6020);
                ClearWarning_Servo1Achse1.Text = "Clear War.";
                this.Controls.Add(ClearWarning_Servo1Achse1);

                btnClearWarningServo1Achse1 = new Button();
                btnClearWarningServo1Achse1.Location = new Point(1390310);
                btnClearWarningServo1Achse1.Name = "Button Clear Warning Servo1Achse1";
                btnClearWarningServo1Achse1.Size = new Size(2020);
                btnClearWarningServo1Achse1.Text = "";
                this.Controls.Add(btnClearWarningServo1Achse1);
                btnClearWarningServo1Achse1.Click += new EventHandler(btn_ClearWarningServo1Achse1_Click);


                ClearAlarm_Servo1Achse1 = new Label();
                ClearAlarm_Servo1Achse1.Location = new Point(1320340);
                ClearAlarm_Servo1Achse1.Name = "ClearAlarm Servo1Achse1";
                ClearAlarm_Servo1Achse1.Size = new Size(6020);
                ClearAlarm_Servo1Achse1.Text = "Clear Alarm";
                this.Controls.Add(ClearAlarm_Servo1Achse1);

                btnClearAlarmServo1Achse1 = new Button();
                btnClearAlarmServo1Achse1.Location = new Point(1390340);
                btnClearAlarmServo1Achse1.Name = "Button Clear Alarm Servo1Achse1";
                btnClearAlarmServo1Achse1.Size = new Size(2020);
                btnClearAlarmServo1Achse1.Text = "";
                this.Controls.Add(btnClearAlarmServo1Achse1);
                btnClearAlarmServo1Achse1.Click += new EventHandler(btn_ClearAlarmServo1Achse1_Click);

                PositionEingabe_Servo1Achse1 = new Label();
                PositionEingabe_Servo1Achse1.Location = new Point(1430280);
                PositionEingabe_Servo1Achse1.Name = "Position Servo1Achse1";
                PositionEingabe_Servo1Achse1.Size = new Size(8020);
                PositionEingabe_Servo1Achse1.Text = "Position [mm]";
                this.Controls.Add(PositionEingabe_Servo1Achse1);

                tbxPosEingabe_Servo1Achse1 = new TextBox();
                tbxPosEingabe_Servo1Achse1.Location = new Point(1520280);
                tbxPosEingabe_Servo1Achse1.Name = "EingabePosition Servo1Achse1";
                tbxPosEingabe_Servo1Achse1.Text = "0,000";
                tbxPosEingabe_Servo1Achse1.Size = new Size(5020);
                this.Controls.Add(tbxPosEingabe_Servo1Achse1);

                GeschwindigkeitEingabe_Servo1Achse1 = new Label();
                GeschwindigkeitEingabe_Servo1Achse1.Location = new Point(1430310);
                GeschwindigkeitEingabe_Servo1Achse1.Name = "Geschwingkeit Servo1Achse1";
                GeschwindigkeitEingabe_Servo1Achse1.Size = new Size(8020);
                GeschwindigkeitEingabe_Servo1Achse1.Text = "Speed [mm/s]";
                this.Controls.Add(GeschwindigkeitEingabe_Servo1Achse1);

                tbxGeschwEingabe_Servo1Achse1 = new TextBox();
                tbxGeschwEingabe_Servo1Achse1.Location = new Point(1520310);
                tbxGeschwEingabe_Servo1Achse1.Name = "EingabeGeschwindigkeit Servo1Achse1";
                tbxGeschwEingabe_Servo1Achse1.Text = "0,00";
                tbxGeschwEingabe_Servo1Achse1.Size = new Size(5020);
                this.Controls.Add(tbxGeschwEingabe_Servo1Achse1);

                EmpfangeneDaten = new Label();
                EmpfangeneDaten.Location = new Point(1200380);
                EmpfangeneDaten.Name = "Daten empfangen";
                EmpfangeneDaten.Size = new Size(12020);
                EmpfangeneDaten.Text = "Empfangene Daten";
                this.Controls.Add(EmpfangeneDaten);

                HomingDone_Servo1Achse1 = new Label();
                HomingDone_Servo1Achse1.Location = new Point(1200410);
                HomingDone_Servo1Achse1.Name = "HomingDone Servo1Achse1";
                HomingDone_Servo1Achse1.Size = new Size(8020);
                HomingDone_Servo1Achse1.Text = "Homing Done";
                this.Controls.Add(HomingDone_Servo1Achse1);

                btnHomingDoneServo1Achse1 = new Button();
                btnHomingDoneServo1Achse1.Location = new Point(1290410);
                btnHomingDoneServo1Achse1.Name = "Button HomingDone Servo1Achse1";
                btnHomingDoneServo1Achse1.Size = new Size(2020);
                btnHomingDoneServo1Achse1.Text = "";
                this.Controls.Add(btnHomingDoneServo1Achse1);
                btnHomingDoneServo1Achse1.Click += new EventHandler(btn_HomingDoneServo1Achse1_Click);

                TargetPosition_Servo1Achse1 = new Label();
                TargetPosition_Servo1Achse1.Location = new Point(1200440);
                TargetPosition_Servo1Achse1.Name = "TargetPosition Servo1Achse1";
                TargetPosition_Servo1Achse1.Size = new Size(8020);
                TargetPosition_Servo1Achse1.Text = "Target Position";
                this.Controls.Add(TargetPosition_Servo1Achse1);

                btnTargetPositionServo1Achse1 = new Button();
                btnTargetPositionServo1Achse1.Location = new Point(1290440);
                btnTargetPositionServo1Achse1.Name = "Button TargetPosition Servo1Achse1";
                btnTargetPositionServo1Achse1.Size = new Size(2020);
                btnTargetPositionServo1Achse1.Text = "";
                this.Controls.Add(btnTargetPositionServo1Achse1);
                btnTargetPositionServo1Achse1.Click += new EventHandler(btn_TargetPositionServo1Achse1_Click);

                WarningPresent_Servo1Achse1 = new Label();
                WarningPresent_Servo1Achse1.Location = new Point(1200470);
                WarningPresent_Servo1Achse1.Name = "Warning Servo1Achse1";
                WarningPresent_Servo1Achse1.Size = new Size(8020);
                WarningPresent_Servo1Achse1.Text = "Warning";
                this.Controls.Add(WarningPresent_Servo1Achse1);

                btnWarningServo1Achse1 = new Button();
                btnWarningServo1Achse1.Location = new Point(1290470);
                btnWarningServo1Achse1.Name = "Button Warning Servo1Achse1";
                btnWarningServo1Achse1.Size = new Size(2020);
                btnWarningServo1Achse1.Text = "";
                this.Controls.Add(btnWarningServo1Achse1);
                btnWarningServo1Achse1.Click += new EventHandler(btn_WarningPresentServo1Achse1_Click);

                AlarmPresent_Servo1Achse1 = new Label();
                AlarmPresent_Servo1Achse1.Location = new Point(1200500);
                AlarmPresent_Servo1Achse1.Name = "Alarm Servo1Achse1";
                AlarmPresent_Servo1Achse1.Size = new Size(8020);
                AlarmPresent_Servo1Achse1.Text = "Alarm";
                this.Controls.Add(AlarmPresent_Servo1Achse1);

                btnAlarmServo1Achse1 = new Button();
                btnAlarmServo1Achse1.Location = new Point(1290500);
                btnAlarmServo1Achse1.Name = "Button Alarm Servo1Achse1";
                btnAlarmServo1Achse1.Size = new Size(2020);
                btnAlarmServo1Achse1.Text = "";
                this.Controls.Add(btnAlarmServo1Achse1);
                btnAlarmServo1Achse1.Click += new EventHandler(btn_AlarmPresentServo1Achse1_Click);

                AktPosition_Servo1Achse1 = new Label();
                AktPosition_Servo1Achse1.Location = new Point(1320410);
                AktPosition_Servo1Achse1.Name = "AktuellePosition Servo1Achse1";
                AktPosition_Servo1Achse1.Size = new Size(7020);
                AktPosition_Servo1Achse1.Text = "Akt. Pos. [mm]";
                this.Controls.Add(AktPosition_Servo1Achse1);

                tbxAktPosBerechnung_Servo1Achse1 = new TextBox();
                tbxAktPosBerechnung_Servo1Achse1.Location = new Point(1390410);
                tbxAktPosBerechnung_Servo1Achse1.Name = "BerAktPosition Servo1Achse1";
                tbxAktPosBerechnung_Servo1Achse1.ReadOnly = true;
                tbxAktPosBerechnung_Servo1Achse1.Text = "0,000";
                tbxAktPosBerechnung_Servo1Achse1.Size = new Size(5020);
                this.Controls.Add(tbxAktPosBerechnung_Servo1Achse1);

                WarnCode_Servo1Achse1 = new Label();
                WarnCode_Servo1Achse1.Location = new Point(1320440);
                WarnCode_Servo1Achse1.Name = "WarningCode Servo1Achse1";
                WarnCode_Servo1Achse1.Size = new Size(8020);
                WarnCode_Servo1Achse1.Text = "Warn. Code [hex]";
                this.Controls.Add(WarnCode_Servo1Achse1);

                tbxWarnCodeAnzeige_Servo1Achse1 = new TextBox();
                tbxWarnCodeAnzeige_Servo1Achse1.Location = new Point(1400440);
                tbxWarnCodeAnzeige_Servo1Achse1.Name = "AnzeigeWarningCode Servo1Achse1";
                tbxWarnCodeAnzeige_Servo1Achse1.ReadOnly = true;
                tbxWarnCodeAnzeige_Servo1Achse1.Text = "00";
                tbxWarnCodeAnzeige_Servo1Achse1.Size = new Size(4020);
                this.Controls.Add(tbxWarnCodeAnzeige_Servo1Achse1);

                AlarmCode_Servo1Achse1 = new Label();
                AlarmCode_Servo1Achse1.Location = new Point(1320470);
                AlarmCode_Servo1Achse1.Name = "AlarmCode Servo1Achse1";
                AlarmCode_Servo1Achse1.Size = new Size(8020);
                AlarmCode_Servo1Achse1.Text = "Alarm Code [hex]";
                this.Controls.Add(AlarmCode_Servo1Achse1);

                tbxAlarmCodeAnzeige_Servo1Achse1 = new TextBox();
                tbxAlarmCodeAnzeige_Servo1Achse1.Location = new Point(1400470);
                tbxAlarmCodeAnzeige_Servo1Achse1.Name = "AnzeigeAlarmCode Servo1Achse1";
                tbxAlarmCodeAnzeige_Servo1Achse1.ReadOnly = true;
                tbxAlarmCodeAnzeige_Servo1Achse1.Text = "00";
                tbxAlarmCodeAnzeige_Servo1Achse1.Size = new Size(4020);
                this.Controls.Add(tbxAlarmCodeAnzeige_Servo1Achse1);

            }
}


Moderiert von user profile iconChristian S.: C#-Tags hinzugefügt


Zuletzt bearbeitet von IsabelleZimmermann am Mi 16.01.19 09:56, insgesamt 1-mal bearbeitet
Frühlingsrolle
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 15.01.19 17:33 
- Nachträglich durch die Entwickler-Ecke gelöscht -
Chiyoko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 298
Erhaltene Danke: 8

Win 98, Win Xp, Win 10
C# / C (VS 2019)
BeitragVerfasst: Mi 16.01.19 09:32 
Wenn ich das richtig verstanden habe....

Erstelle dir erstmal eine Struktur für deine/n Motor/en als Klasse und dessen Properties und daraus eine Liste als DataSource, die du ans Control binden kannst.

Je nach ausgewählten Index kannst du jetzt in der Buttonfunktion die gewählte Instanz abfragen.
Du kannst auch Werte im "Tag" von einem Control zwischen speichern, aber die Variante ist nicht zu empfehlen.
IsabelleZimmermann Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54



BeitragVerfasst: Mi 16.01.19 12:08 
Ich komme gerade nicht weiter.
Jetzt hab ich eine unabhängige Klasse Motoren erstellt mit den Eigenschaften. Die Eigenschaften hab ich mit form1.Controls.Add() zu form1 hinzugefügt.

Die Funktion ServoMotore_Einblenden enthält jetzt eine Instanziierung der Klasse Motoren und eine Liste mit Motorobjekten.

Allerdings, wenn ich im Form1 auf "ServoMotoren" klicke, werden keine Labels, Textboxen und Buttons mehr angezeigt.
Was mache ich falsch?

Mein Code:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
void ServoMotoren_Einblenden(object sender, EventArgs e)
{
        Program.Form1.Motoren servoMotoren = new Program.Form1.Motoren();
        this.Show();

        // Eine Liste erstellen mit Motorenobjekten und deren Eigenschaften
        List<Motoren> Form1Motoren = new List<Motoren>() { };

        // Die Liste an die Binding Source binden

}


Moderiert von user profile iconTh69: C#-Tags hinzugefügt
IsabelleZimmermann Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54



BeitragVerfasst: Mi 16.01.19 12:27 
Ich hab den Fehler gefunden.
Jetzt öffnet sich ein neues Fenster mit den Eigenschaften der Motoren.

Allerdings komme ich mit dem Data Binding der Liste noch nicht zurecht.
IsabelleZimmermann Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54



BeitragVerfasst: Mi 16.01.19 18:09 
Ich konnte das Problem heute auch lösen.
Vielen Dank.