cs_veler
Messages postés723Date d'inscriptiondimanche 26 novembre 2006StatutMembreDernière intervention23 janvier 2013
-
21 févr. 2007 à 12:28
cs_veler
Messages postés723Date d'inscriptiondimanche 26 novembre 2006StatutMembreDernière intervention23 janvier 2013
-
21 févr. 2007 à 13:01
Bonjours tous le monde, j'apprend à utiliser les mdi.
J'arrive sans problême à appeller un Child avec un RichTextBox dedans mais quand je veux ouvrir un fichier et l'afficher dans le RichTextBox, sa ne fonctionne pas, même pas de message d'erreur, le RichTextBox est vide, voila mon code. Pouvez-vous me dire ou sont les erreurs (et si vous êtes hyper simpa, les corrigé)...
Dim frm As New Form2()
frm.MdiParent = Me
frm.Visible = True
frm.Name = "Editeur de HTML"
OpenFileDialog1.Filter = "Tous les fichies(*.*)|*.*"
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
FileOpen(1, OpenFileDialog1.FileName, OpenMode.Input)
Do Until EOF(1)
strLineofText = LineInput(1)
strAllText &= strLineofText & vbCrLf
Loop
Dim frm As New Form2()
frm.MdiParent = Me
frm.Visible = True
frm.Name = OpenFileDialog1.FileName
Form2.RichTextBox1.Text = strAllText
FileClose(1)
End If
Form2.RichTextBox1.Focus()
cs_veler
Messages postés723Date d'inscriptiondimanche 26 novembre 2006StatutMembreDernière intervention23 janvier 20132 21 févr. 2007 à 13:01
Re, laissez tomber, je suis tros con, je ne m'y été pas pris dans le bon sans, sa fonctionne maintenant. Pour les curieux,je vous donnes le code source que j'ai trouvé:
Dim Nomlong, Nomcourt As String
Dim lon, tutu As Integer
Dim ext As String
OpenFileDialog1.Filter = "Fichier HTML(*.html)|*.html|Fichier HTM(*.htm)|*.htm|Fichier SHTML(*.shtml)|*.shtml|Fichier Texte(*.txt)|*.txt|Fichier RTF(*.rtf)|*.rtf|Tous les fichies(*.*)|*.*"
OpenFileDialog1.ShowDialog()
Nomlong = OpenFileDialog1.FileName
If Nomlong <> ""Then
lon = Nomlong.Length
ext = Nomlong.Substring(lon - 3, 3) If ext "html"Or ext "htm"Or ext = "shtml"Or ext = "txt" Or ext = "rtf"Or ext = "*"Then
' Création de la nouvelle form
Dim x As New Form2
x.MdiParent = Me
x.Visible = True
' Récupération du nom du fichier
Dim anti As Integer = lon - 4
While Nomlong.Substring(anti, 1) <> ""
anti = anti - 1
End While
Nomcourt = Nomlong.Substring(anti + 1, lon - anti - 1)
x.Text = Nomcourt
'On vide le RichTextBox
x.RichTextBox1.Text = String.Empty
'Ouverture du fichier sélectionné
'son nom est dans openFileDialog1.FileName
Dim sr As StreamReader = New StreamReader(OpenFileDialog1.OpenFile, True)
Try
Dim data As String = sr.ReadLine
While Not (data Is Nothing)
x.RichTextBox1.AppendText(data + _
Convert.ToChar(13) + _
Convert.ToChar(10))
data = sr.ReadLine()
End While
Finally
If Not (sr Is Nothing) Then
sr.Close()
End If
End Try
Else
tutu = MsgBox("Ceci n'est pas un fihier valide", MsgBoxStyle.Information, "Opération annulée")
End If
End If