|
| Autor |
Nachricht |
speedywolf Poster

Anmeldedatum: 01.05.2008 Beiträge: 108
|
Schrift-grösse, -farbe
Verfasst am: 23.08.2008, 22:09 |
|
|
Hab da ein kleines Notepad geschrieben. Habe paar Funktionen hinzugefügt wie: Farbe ändern und Grösse ändern. Wenn ich jetzt die RichTextBox abspeichere und dann wieder öffne, steht zwar mein Text da, aber die geänderte Schrift-grösse und/oder -farbe ist verschwunden.
Mein Sourcecode:
Visual Basic: [code] 'Erstellen des Textes Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
With SaveFileDialog1
.Filter = "Textdateien|*.txt|Alle Dateien|*.*"
.DefaultExt = "txt"
If .ShowDialog = Windows.Forms.DialogResult.OK And .FileName <> vbNullString Then
Dim outputstream As New IO.StreamWriter(.FileName)
outputstream.Write(RichTextBox1.Text)
outputstream.Close()
End If
End With Button1.Visible = False Button3.Visible = True End Sub
'Laden des Textes Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
With OpenFileDialog1
.Filter = "Textdateien|*.txt"
.DefaultExt = "txt"
If .ShowDialog = Windows.Forms.DialogResult.OK And .FileName <> vbNullString Then
Dim inputstream As New IO.StreamReader(.FileName)
RichTextBox1.Text = inputstream.ReadToEnd
inputstream.Close()
End If
End With Button1.Visible = False Button3.Visible = True
End Sub
'Speichern des Textes Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click With SaveFileDialog1
.Filter = "Textdateien|*.txt|Alle Dateien|*.*"
.DefaultExt = "txt"
If .ShowDialog = Windows.Forms.DialogResult.OK And .FileName <> vbNullString Then
Dim outputstream As New IO.StreamWriter(.FileName)
outputstream.Write(RichTextBox1.Text)
outputstream.Close()
End If
End With End Sub
'Farbe aendern Private Sub cb_color_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cb_color.SelectedIndexChanged
If cb_color.Text = "Blau" Then RichTextBox1.SelectionColor = Color.Blue End If
If cb_color.Text = "Gelb" Then RichTextBox1.SelectionColor = Color.Yellow End If
If cb_color.Text = "Grün" Then RichTextBox1.SelectionColor = Color.Green End If
End Sub
'Grösse aendern Private Sub cb_size_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cb_size.SelectedIndexChanged
If cb_size.Text = "10" Then RichTextBox1.SelectionFont = New Font("", 10, FontStyle.Regular) End If
If cb_size.Text = "20" Then RichTextBox1.SelectionFont = New Font("", 20, FontStyle.Regular) End If
If cb_size.Text = "30" Then RichTextBox1.SelectionFont = New Font("", 30, FontStyle.Regular) End If
End Sub[/code] |
|
| |
|
 |
^^kev#### Überflieger

Anmeldedatum: 01.05.2008 Beiträge: 476 Wohnort: Haan
|
Verfasst am: 23.08.2008, 22:41 |
|
|
Sieht ja schonmal Nice aus  Hatte vor längerer Zeit auch mal einen Editor angefangen, hatte dann aber wieder neue Ideen für andere Sachen [img]/rolleyes.gif[/img]

|
|
| |
|
 |
speedywolf Poster

Anmeldedatum: 01.05.2008 Beiträge: 108
|
Verfasst am: 23.08.2008, 22:45 |
|
|
Wow! Sieht schon richtig geil aus! Aber ja.. Helfen tuts ned  |
|
| |
|
 |
^^kev#### Überflieger

Anmeldedatum: 01.05.2008 Beiträge: 476 Wohnort: Haan
|
Verfasst am: 23.08.2008, 23:02 |
|
|
Sry hatte die Frage übersehen  Du musst das ganze als RTF speichern dann müsste das auch gehen 
RichTextBox1.SaveFile(SaveFileDialog1.FileName)
|
|
| |
|
 |
speedywolf Poster

Anmeldedatum: 01.05.2008 Beiträge: 108
|
Verfasst am: 23.08.2008, 23:07 |
|
|
Hab jetzt als .rtf eingestellt. Aber wo muss ich RichTextBox1.SaveFile(SaveFileDialog1.FileName) einfügen? Muss ich da was zuerst löschen?
Neuer Code: (ohne RichTextBox1.SaveFile(SaveFileDialog1.FileName) )
Visual Basic: [code] Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 'Laden des Textes With OpenFileDialog1
.Filter = "RTF Dateien by Burak (*.rtf)|*.rtf"
.DefaultExt = "rtf"
If .ShowDialog = Windows.Forms.DialogResult.OK And .FileName <> vbNullString Then
Dim inputstream As New IO.StreamReader(.FileName)
RichTextBox1.Text = inputstream.ReadToEnd
inputstream.Close()
End If
End With Button1.Visible = False Button3.Visible = True
End Sub
'Speichern des Textes Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click With SaveFileDialog1
.Filter = "RTF Dateien by Burak (*.rtf)|*.rtf"
.DefaultExt = "rtf"
If .ShowDialog = Windows.Forms.DialogResult.OK And .FileName <> vbNullString Then
Dim outputstream As New IO.StreamWriter(.FileName)
outputstream.Write(RichTextBox1.Text)
outputstream.Close()
End If
End With End Sub
'Farbe aendern Private Sub cb_color_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cb_color.SelectedIndexChanged
If cb_color.Text = "Blau" Then RichTextBox1.SelectionColor = Color.Blue End If
If cb_color.Text = "Gelb" Then RichTextBox1.SelectionColor = Color.Yellow End If
If cb_color.Text = "Grün" Then RichTextBox1.SelectionColor = Color.Green End If
End Sub
'Grösse aendern Private Sub cb_size_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cb_size.SelectedIndexChanged
If cb_size.Text = "10" Then RichTextBox1.SelectionFont = New Font("", 10, FontStyle.Regular) End If
If cb_size.Text = "20" Then RichTextBox1.SelectionFont = New Font("", 20, FontStyle.Regular) End If
If cb_size.Text = "30" Then RichTextBox1.SelectionFont = New Font("", 30, FontStyle.Regular) End If
End Sub[/code] |
|
| |
|
 |
^^kev#### Überflieger

Anmeldedatum: 01.05.2008 Beiträge: 476 Wohnort: Haan
|
Verfasst am: 23.08.2008, 23:18 |
|
|
Visual Basic: [code]Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
With SaveFileDialog1
.Filter = "RTF Dateien by Burak (*.rtf)|*.rtf"
.DefaultExt = "rtf"
If .ShowDialog = Windows.Forms.DialogResult.OK And .FileName <> vbNullString Then
RichTextBox1.SaveFile(SaveFileDialog1.FileName)
End If
End With
End Sub[/code]
|
|
| |
|
 |
speedywolf Poster

Anmeldedatum: 01.05.2008 Beiträge: 108
|
Verfasst am: 23.08.2008, 23:22 |
|
|
Habe es vorhin auch so versucht. Ergebnis nach laden: (Als Text hab ich LOL in blau geschrieben)
Visual Basic: [code]{rtf1ansiansicpg1252deff0deflang2055{fonttbl{f0fnilfcharset0 Microsoft Sans Serif;}} {colortbl ;red0green0blue255;} viewkind4uc1pardcf1f0fs17 LOLcf0par } [/code] |
|
| |
|
 |
^^kev#### Überflieger

Anmeldedatum: 01.05.2008 Beiträge: 476 Wohnort: Haan
|
Verfasst am: 23.08.2008, 23:23 |
|
|
Müsste so gehen
Visual Basic: [code]Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Laden des Textes
With OpenFileDialog1
.Filter = "RTF Dateien by Burak (*.rtf)|*.rtf"
.DefaultExt = "rtf"
If .ShowDialog = Windows.Forms.DialogResult.OK And .FileName <> vbNullString Then
Dim obFi As FileStream = New FileStream(OpenFileDialog1.FileName, FileMode.Open)
Dim obStw As StreamReader = New StreamReader(obFi)
RichTextBox1.Rtf = obStw.ReadToEnd
End If
End With
Button1.Visible = False
Button3.Visible = True
End Sub[/code]
|
|
| |
|
 |
speedywolf Poster

Anmeldedatum: 01.05.2008 Beiträge: 108
|
Verfasst am: 23.08.2008, 23:28 |
|
|
Super! Mein Held!! :p Kann man nun closen  |
|
| |
|
 |