Ansicht auf der Form wird zerschossen

  • VB.NET

Es gibt 4 Antworten in diesem Thema. Der letzte Beitrag () ist von RodFromGermany.

    Ansicht auf der Form wird zerschossen

    Hallo Liebe Gemeinde,

    Ich habe eine Programm welches eine Eingabemaske öffnet.
    Auf diese Makse wird eine Stückliste erstellt, welche bis zu 30 Positionen haben kann.
    Bis zur Position 7 ist alles super (Bis hier wird die komplette Größe der Eingabemaske nciht überschritten).

    Aber ab Position 8 wird der Abstand zwischen den Zeilen immer Größer und bleibt nicht wie gewünscht gleich.
    (Ab hier wird der Scrollbalken aktiv, da nicht mehr alles auf die Fom passt)

    Kenn jemand dieses Problem und weiß wie man sich da helfen kann?

    Hier mein Code zum erstellen der Stückliste:

    VB.NET-Quellcode

    1. Sub StücklisteErstellen()
    2. Zeilenabstand = 60
    3. For i = 1 To Anzahl
    4. txtNr(i) = New System.Windows.Forms.TextBox
    5. Me.Controls.Add(txtNr(i))
    6. With txtNr(i)
    7. .Name = "txtNr" & i
    8. .Size = New System.Drawing.Size(30, 23)
    9. .Location = New System.Drawing.Point(15, 440 + ((i - 1) * Zeilenabstand))
    10. .Visible = True
    11. .Font = New Drawing.Font("ISOCPEUR", 10)
    12. .Text = i
    13. .AcceptsReturn = False
    14. .Multiline = False
    15. End With
    16. txtStk(i) = New System.Windows.Forms.TextBox
    17. Me.Controls.Add(txtStk(i))
    18. With txtStk(i)
    19. .Name = "txtStk" & i
    20. .Size = New System.Drawing.Size(30, 23)
    21. .Location = New System.Drawing.Point(58, 440 + ((i - 1) * Zeilenabstand))
    22. .Visible = True
    23. .Font = New Drawing.Font("ISOCPEUR", 10)
    24. .Text = Stück(i)
    25. .AcceptsReturn = False
    26. .Multiline = False
    27. End With
    28. txtBezSt(i) = New System.Windows.Forms.TextBox
    29. Me.Controls.Add(txtBezSt(i))
    30. With txtBezSt(i)
    31. .Name = "txtBezSt" & i
    32. .Size = New System.Drawing.Size(180, 23)
    33. .Location = New System.Drawing.Point(101, 440 + ((i - 1) * Zeilenabstand))
    34. .Visible = True
    35. .Font = New Drawing.Font("ISOCPEUR", 10)
    36. .Text = Bezeichnung(i)
    37. .AcceptsReturn = False
    38. .Multiline = False
    39. End With
    40. txtBezStEngl(i) = New System.Windows.Forms.TextBox
    41. AddHandler txtBezStEngl(i).GotFocus, AddressOf txtBezStEngl_GotFocus
    42. Me.Controls.Add(txtBezStEngl(i))
    43. With txtBezStEngl(i)
    44. .Name = "txtBezStEngl" & i
    45. .Size = New System.Drawing.Size(120, 23)
    46. .Location = New System.Drawing.Point(101, 463 + ((i - 1) * Zeilenabstand))
    47. .Visible = True
    48. .Font = New Drawing.Font("ISOCPEUR", 8)
    49. .Text = BezeichnungEngl(i)
    50. .AcceptsReturn = False
    51. .Multiline = False
    52. End With
    53. txtBen(i) = New System.Windows.Forms.TextBox
    54. Me.Controls.Add(txtBen(i))
    55. With txtBen(i)
    56. .Name = "txtBen" & i
    57. .Size = New System.Drawing.Size(180, 23)
    58. .Location = New System.Drawing.Point(294, 440 + ((i - 1) * Zeilenabstand))
    59. .Visible = True
    60. .Font = New Drawing.Font("ISOCPEUR", 10)
    61. .Text = Benennung(i)
    62. .AcceptsReturn = False
    63. .Multiline = False
    64. End With
    65. txtMat(i) = New System.Windows.Forms.TextBox
    66. Me.Controls.Add(txtMat(i))
    67. With txtMat(i)
    68. .Name = "txtMat" & i
    69. .Size = New System.Drawing.Size(65, 23)
    70. .Location = New System.Drawing.Point(487, 440 + ((i - 1) * Zeilenabstand))
    71. .Visible = True
    72. .Font = New Drawing.Font("ISOCPEUR", 10)
    73. .Text = Material(i)
    74. .AcceptsReturn = False
    75. .Multiline = False
    76. End With
    77. txtMatDIN(i) = New System.Windows.Forms.TextBox
    78. Me.Controls.Add(txtMatDIN(i))
    79. With txtMatDIN(i)
    80. .Name = "txtMatDIN" & i
    81. .Size = New System.Drawing.Size(65, 23)
    82. .Location = New System.Drawing.Point(487, 463 + ((i - 1) * Zeilenabstand))
    83. .Visible = True
    84. .Font = New Drawing.Font("ISOCPEUR", 10)
    85. .Text = MaterialDIN(i)
    86. .AcceptsReturn = False
    87. .Multiline = False
    88. End With
    89. txtAPZ(i) = New System.Windows.Forms.TextBox
    90. Me.Controls.Add(txtAPZ(i))
    91. With txtAPZ(i)
    92. .Name = "txtAPZ" & i
    93. .Size = New System.Drawing.Size(120, 23)
    94. .Location = New System.Drawing.Point(565, 440 + ((i - 1) * Zeilenabstand))
    95. .Visible = True
    96. .Font = New Drawing.Font("ISOCPEUR", 10)
    97. .Text = APZ(i)
    98. .AcceptsReturn = False
    99. .Multiline = False
    100. End With
    101. txtTNr(i) = New System.Windows.Forms.TextBox
    102. Me.Controls.Add(txtTNr(i))
    103. With txtTNr(i)
    104. .Name = "txtTNr" & i
    105. .Size = New System.Drawing.Size(65, 23)
    106. .Location = New System.Drawing.Point(708, 440 + ((i - 1) * Zeilenabstand))
    107. .Visible = True
    108. .Font = New Drawing.Font("ISOCPEUR", 10)
    109. .Text = TeileNr(i)
    110. .AcceptsReturn = False
    111. .Multiline = False
    112. End With
    113. txtMVN(i) = New System.Windows.Forms.TextBox
    114. Me.Controls.Add(txtMVN(i))
    115. With txtMVN(i)
    116. .Name = "txtMVN" & i
    117. .Size = New System.Drawing.Size(50, 23)
    118. .Location = New System.Drawing.Point(786, 440 + ((i - 1) * Zeilenabstand))
    119. .Visible = True
    120. .Font = New Drawing.Font("ISOCPEUR", 10)
    121. .Text = MVN(i)
    122. .AcceptsReturn = False
    123. .Multiline = False
    124. End With
    125. ComboSuchTNr(i) = New System.Windows.Forms.ComboBox
    126. AddHandler ComboSuchTNr(i).SelectedIndexChanged, AddressOf ComboBoxes_IndexChanged
    127. Me.Controls.Add(ComboSuchTNr(i))
    128. With ComboSuchTNr(i)
    129. .Name = "ComboSuchTNr" & i
    130. .Size = New System.Drawing.Size(300, 45)
    131. .Location = New System.Drawing.Point(870, 440 + ((i - 1) * Zeilenabstand))
    132. .Visible = True
    133. .Font = New Drawing.Font("ISOCPEUR", 8)
    134. .DropDownStyle = Windows.Forms.ComboBoxStyle.DropDownList
    135. End With
    136. ComboSuchTNr(i).Items.Add(TNrSuch(i))
    137. ComboSuchTNr(i).SelectedIndex = 0
    138. LabVerfügbar(i) = New System.Windows.Forms.Label
    139. Me.Controls.Add(LabVerfügbar(i))
    140. With LabVerfügbar(i)
    141. .Name = "LabVerfügbar" & i
    142. .Size = New System.Drawing.Size(300, 20)
    143. .Location = New System.Drawing.Point(870, 470 + ((i - 1) * Zeilenabstand))
    144. .Visible = True
    145. .Font = New Drawing.Font("ISOCPEUR", 10)
    146. .Text = VerfügbarSuch(i)
    147. End With
    148. txtBezStEngl(i).Focus()
    149. Next
    150. End Sub
    Wir wäre es, statt Textboxen/ComboBoxen einfach ein DataGridView zu nehmen?
    "Gib einem Mann einen Fisch und du ernährst ihn für einen Tag. Lehre einen Mann zu fischen und du ernährst ihn für sein Leben."

    Wie debugge ich richtig? => Debuggen, Fehler finden und beseitigen
    Wie man VisualStudio nutzt? => VisualStudio richtig nutzen
    @fiedel93felix Wenn, dann pack zusammengehörige Controls in ein separates eigenes Userontrol und mehrere davon in ein TableLayoutPanel.
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    Vielen Dank für die Antworten.
    Ein Datagrid zu verwenden find ich und versuch jetzt das umzusetzten.

    Ich habe jetzt ohne Probleme das DataGridView ausgefüllt.
    Mein Problem ist jetzt:
    Ich habe Comboboxen mit drin und möchte zur Laufzeit den Index setzten oder Abfragen.
    Bei normalen Comboboxen geht das ja über.selectedIndex aber wir funktioniert das in eiem Datagridview???

    Leider finde ich hier keine Lösung, habe schon eine Weile gesucht.
    @fiedel93felix Mit der Google-Anfrage datagridview combobox selectedindex dürfte bereits der 1. Treffer ein Treffer sein.
    stackoverflow.com/questions/48…atagridviewcomboboxcolumn
    stackoverflow.com/questions/53…umn-set-the-selectedindex
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!