Click here to Skip to main content
16,005,236 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Saving font parameters to a Text file Pin
PatriceB29-Sep-05 23:54
PatriceB29-Sep-05 23:54 
GeneralRe: Saving font parameters to a Text file Pin
militiaware30-Sep-05 3:50
militiaware30-Sep-05 3:50 
GeneralRe: Saving font parameters to a Text file Pin
PatriceB30-Sep-05 6:52
PatriceB30-Sep-05 6:52 
GeneralRe: Saving font parameters to a Text file Pin
rwestgraham30-Sep-05 9:46
rwestgraham30-Sep-05 9:46 
GeneralRe: Saving font parameters to a Text file Pin
PatriceB30-Sep-05 13:56
PatriceB30-Sep-05 13:56 
GeneralRe: Saving font parameters to a Text file Pin
rwestgraham30-Sep-05 15:40
rwestgraham30-Sep-05 15:40 
GeneralRe: Saving font parameters to a Text file Pin
PatriceB1-Oct-05 1:44
PatriceB1-Oct-05 1:44 
GeneralRe: Saving font parameters to a Text file Pin
PatriceB1-Oct-05 6:12
PatriceB1-Oct-05 6:12 
So guys, with your help I have got it working pretty nice.

To put it all together and to clean up the table, for those interested:

How to save and restore fonts and colors from controls: (if there is a better way to do it just tell)

' Saving the parameters<br />
Dim sw As New StreamWriter("myInitFile.ini")<br />
            ' Color of Caracters<br />
            sw.WriteLine(RichTextBox1.ForeColor.ToArgb)<br />
            sw.WriteLine(ListView1.ForeColor.ToArgb)<br />
            ' Color of Background<br />
            sw.WriteLine(RichTextBox1.BackColor.ToArgb)<br />
            sw.WriteLine(ListView1.BackColor.ToArgb)<br />
            'Fonts<br />
            sw.WriteLine(RichTextBox1.Font.Name)<br />
            sw.WriteLine(ListView1.Font.Name)<br />
            'Size<br />
            sw.WriteLine(RichTextBox1.Font.SizeInPoints)<br />
            sw.WriteLine(ListView1.Font.SizeInPoints)<br />
            sw.close()<br />
<br />
' retriving the parameters<br />
                Dim sr As New StreamReader("myInitFile.ini")<br />
                delimStr1 As String = "[] :,.=;"<br />
                Dim delimiter As Char() = delimStr1.ToCharArray()<br />
                Dim split As String() = Nothing<br />
                Dim i, Pos, First As Integer<br />
                Dim Words, s As String<br />
                Dim token(16) As String<br />
                For i = 1 To 6<br />
                    token(i) = sr.ReadLine<br />
                Next i<br />
                Pos = 6<br />
                For i = 1 To 2<br />
                    Words = sr.ReadLine<br />
                    split = Words.Split(delimiter)<br />
                    Pos += 1<br />
                    First = 0<br />
                    For Each s In split<br />
                        If s <> "" Then<br />
                            First += 1<br />
                            If First = 1 Then<br />
                                token(Pos) = s<br />
                            End If<br />
                        End If<br />
                    Next s<br />
                Next i<br />
<br />
   RichTextBox1.ForeColor = Color.FromArgb(CInt(Val(token(1))))<br />
   ListView1.ForeColor = Color.FromArgb(CInt(Val(token(2))))<br />
   RichTextBox1.BackColor = Color.FromArgb(CInt(Val(token(3))))<br />
   ListView1.BackColor = Color.FromArgb(CInt(Val(token(4))))<br />
   RichTextBox1.Font = New Font(token(5), CShort(Val(token(7))))<br />
   ListView1.Font = New Font(token(6), CShort(Val(token(8))))<br />
   sr.close()<br />

That's all folks!
This is a simplified extract of my program which work nice. This is my little contribution and thanks your help.
Best regards


Patrice
GeneralRe: Saving font parameters to a Text file Pin
rwestgraham1-Oct-05 10:50
rwestgraham1-Oct-05 10:50 
QuestionPushing data to Excel Pin
Member 228077329-Sep-05 6:32
Member 228077329-Sep-05 6:32 
QuestionExport to app.config file Pin
PHDENG8129-Sep-05 6:26
PHDENG8129-Sep-05 6:26 
QuestionEfficient way to clear all controls on page Pin
jszpila29-Sep-05 6:24
jszpila29-Sep-05 6:24 
AnswerRe: Efficient way to clear all controls on page Pin
_mubashir29-Sep-05 23:12
_mubashir29-Sep-05 23:12 
GeneralRe: Efficient way to clear all controls on page Pin
jszpila30-Sep-05 4:14
jszpila30-Sep-05 4:14 
GeneralRe: Efficient way to clear all controls on page Pin
jszpila30-Sep-05 4:23
jszpila30-Sep-05 4:23 
Questioncontextmenu right click Pin
andy3829-Sep-05 6:04
andy3829-Sep-05 6:04 
QuestionVisual Basic IDE Pin
theart29-Sep-05 3:45
theart29-Sep-05 3:45 
AnswerRe: Visual Basic IDE Pin
Brian Van Beek29-Sep-05 5:17
Brian Van Beek29-Sep-05 5:17 
GeneralRe: Visual Basic IDE Pin
Anonymous29-Sep-05 22:38
Anonymous29-Sep-05 22:38 
GeneralRe: Visual Basic IDE Pin
S Douglas30-Sep-05 0:33
professionalS Douglas30-Sep-05 0:33 
QuestionExporting to XML Pin
PHDENG8129-Sep-05 2:10
PHDENG8129-Sep-05 2:10 
AnswerRe: Exporting to XML Pin
Dave Kreskowiak29-Sep-05 2:49
mveDave Kreskowiak29-Sep-05 2:49 
GeneralRe: Exporting to XML Pin
PHDENG8129-Sep-05 3:22
PHDENG8129-Sep-05 3:22 
Questioneclipse for vb.net programming Pin
chitranjan gohil28-Sep-05 23:36
chitranjan gohil28-Sep-05 23:36 
QuestionFinalize and dispose Pin
Rajesh_K_Sharma28-Sep-05 23:08
Rajesh_K_Sharma28-Sep-05 23:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.