Form Rückstände auf anderem Form

  • VB.NET

Es gibt 25 Antworten in diesem Thema. Der letzte Beitrag () ist von schnibli.

    Hallo im Falle ich das 2.Form Modal aufrufe und wieder schliesse bleiben kein Rückstände.
    Im falle ich die 2.Form nich Modal aufrufe und wieder schliessen bleiben Rückstände auf dem 1. Form

    Kann ich nun Das 2. Form irgendwie nicht Modal aufrufen und dennoch die Rückstände beseitigen?

    Ach ja wenn ich das Form nicht modal aufrufe bleibt das 1 Form nicht hängen. Nur wenn ich das 2.Form schließe bleibt es kurz hängen und dann habe ich die Rückstände...
    Auch wenn mir der Fehler komisch vorkommt, und eigentlich gar nicht sein dürfte..
    vielleicht hilft da nur noch die Holzhammermethode, Nach dem Motto: "Ungewöhnliche Dinge erfordern ungewöhnliche Maßnahmen" :)
    Entferne im Close.Event einfach all deine Controls, und Ruhe ist ! (natürlich in der richtigen Form aufgerufen)

    VB.NET-Quellcode

    1. Private Sub Form1_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
    2. Me.Controls.Clear()
    3. End Sub
    Hallo Snaptu,

    Ich habe in post 2 den Aufruf und in Post 3 das ganze Form.

    Aufruf:

    VB.NET-Quellcode

    1. kontakte.Show()


    Form:

    VB.NET-Quellcode

    1. Imports System.Reflection
    2. Imports Outlook = Microsoft.Office.Interop.Outlook
    3. Imports System.Windows
    4. Public Class kontakte
    5. Private Sub kontakte_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
    6. Dim text As String = ""
    7. For Each Litem As String In Start.ListBox2.Items
    8. text &= vbCrLf & Litem
    9. Next
    10. IO.File.WriteAllText(My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\Ordner\kontakte.txt", text)
    11. 'Form schliessen
    12. If System.IO.File.Exists(System.IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.MyDocuments & "Ordner\kontakte.txt")) Then
    13. Dim lines() As String = System.IO.File.ReadAllLines(My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\Ordner\kontakte.txt")
    14. End If
    15. Me.Close()
    16. End Sub
    17. Private Sub kontakte_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    18. Dim p() As Process = Process.GetProcessesByName("Outlook")
    19. If p.Length = 0 Then
    20. Dim ExterneAnwendung As New System.Diagnostics.Process()
    21. ExterneAnwendung.StartInfo.FileName = "outlook.exe"
    22. ExterneAnwendung.Start()
    23. End If
    24. Dim oApp As Outlook.Application = New Outlook.Application()
    25. Dim contact As Object
    26. ' Get NameSpace and Logon.
    27. Dim oNS As Outlook.NameSpace = oApp.GetNamespace("mapi")
    28. oNS.Logon("Outlook", Missing.Value, False, True)
    29. Dim oContacts As Outlook.MAPIFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
    30. Dim oItems As Outlook.Items = oContacts.Items
    31. Dim oAppt As Outlook.ContactItem = oContacts.Items.GetNext
    32. Dim contactscounter = oContacts.Items.Count
    33. Dim i As Integer
    34. For Each Contact1 As Outlook.ContactItem In oItems
    35. Dim NewKontakteRow As DataRow = Kontakt.Tables("kontakte").NewRow()
    36. NewKontakteRow("gespeicher") = Contact1.FileAs
    37. NewKontakteRow("vorname") = Contact1.FirstName
    38. NewKontakteRow("nachname") = Contact1.LastName
    39. NewKontakteRow("business_phone") = Contact1.BusinessTelephoneNumber
    40. NewKontakteRow("mobile_phone") = Contact1.MobileTelephoneNumber
    41. NewKontakteRow("home_phone") = Contact1.HomeTelephoneNumber
    42. Kontakt.Kontakte.Rows.Add(NewKontakteRow)
    43. Start.ListBox2.Items.Add(Contact1.FileAs & ";" & Contact1.FirstName & ";" & Contact1.LastName & ";" & Contact1.LastName & ";" & Contact1.BusinessTelephoneNumber & ";" & Contact1.MobileTelephoneNumber & ";" & Contact1.HomeTelephoneNumber)
    44. Next
    45. ' Log off.
    46. oNS.Logoff()
    47. ' Clean up.
    48. oApp = Nothing
    49. oNS = Nothing
    50. oItems = Nothing
    51. oAppt = Nothing
    52. End Sub
    53. Private Sub KontakteDataGridView_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
    54. End Sub
    55. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    56. If RadioButton1.Checked = True Then
    57. Start.txt_nr.Text = Business_phoneTextBox.Text
    58. ElseIf RadioButton2.Checked = True Then
    59. Start.txt_nr.Text = Mobile_phoneTextBox.Text
    60. ElseIf RadioButton3.Checked = True Then
    61. Start.txt_nr.Text = Home_phoneTextBox.Text
    62. End If
    63. Close()
    64. End Sub
    65. Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
    66. Me.KontakteBindingSource.Filter = String.Format("[gespeicher]" & " LIKE '{0}%'", "*" & Me.TextBox1.Text, "typ Like " & " 'Artikel'")
    67. End Sub
    68. Private Sub KontakteDataGridView_CellPainting(sender As Object, e As DataGridViewCellPaintingEventArgs) Handles KontakteDataGridView.CellPainting
    69. With KontakteDataGridView
    70. .RowsDefaultCellStyle.BackColor = Color.White
    71. .RowsDefaultCellStyle.ForeColor = Color.Black
    72. .AlternatingRowsDefaultCellStyle.BackColor = Color.AliceBlue
    73. .AlternatingRowsDefaultCellStyle.ForeColor = Color.Black
    74. End With
    75. End Sub
    76. End Class
    @schnibli Kannst Du vllt. ein kleines ansonsten leeres Testprojekt machen, das Deinen Effekt reproduziert, und dieses hochladen?
    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!