Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27203

One tapstrip at top and one Fastcoloredtextbox

$
0
0
Hi everyone,
I am haveing trouble getting this to work! I have one tabcontrol pulled up to just show tabs and underneath I have one "FastColoredTextBox" http://www.codeproject.com/Articles/...x-highlighting and what I want to do is when the user clicks on a different tab it opens the file associated with that tab!
Here is what I have so far from a test project
Code:

Imports System.IO
Imports FastColoredTextBoxNS
Imports System.Text

Public Class Form1

    Public Function maketab()
        Dim fileName As String
        Dim tp As New Qios.DevSuite.Components.QTabPage
        tcTop.Controls.Add(tp)
        fileName = System.IO.Path.GetFullPath("NewDocument.txt")
        tp.Text = fileName
        tcTop.ActiveTabPage = tp
        tcTop.ActiveTabPage.Tag = fileName
        Return tp
        fctb.AddStyle(New MarkerStyle(New SolidBrush(Color.FromArgb(50, Color.Gray))))
    End Function

    Private Sub btnNew_Click(sender As Object, e As EventArgs) Handles btnNew.Click
        maketab()
    End Sub

    Private Sub btnOpen_Click(sender As Object, e As EventArgs) Handles btnOpen.Click
        If ofd1.ShowDialog = Windows.Forms.DialogResult.OK Then
            If fctb.IsChanged = False Then
                tcTop.ActiveTabPage.Dispose()
                maketab()
                fctb.Text = File.ReadAllText(ofd1.FileName)
                tcTop.ActiveTabPage.Text = ofd1.FileName
                'tcTop.ActiveTabPage.Tag = ofd1.FileName
            Else
                If MessageBox.Show("The New Document is modified! Do you want to save first?", "Save?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                    sfd1.ShowDialog()
                    tcTop.ActiveTabPage.Text = sfd1.FileName
                    'tcTop.ActiveTabPage.Tag = sfd1.FileName
                    maketab()
                    fctb.Text = File.ReadAllText(ofd1.FileName)
                    tcTop.ActiveTabPage.Text = ofd1.FileName
                    'tcTop.ActiveTabPage.Tag = ofd1.FileName
                End If
            End If
        End If
    End Sub

    Private Sub tcTop_ActivePageChanged(sender As Object, e As Qios.DevSuite.Components.QTabPageChangeEventArgs) Handles tcTop.ActivePageChanged
        Dim name As String = System.IO.Path.GetFullPath(tcTop.ActiveTabPage.Text)
        Dim filePath As FileInfo = New FileInfo(name)
        Dim sr As StreamReader = filePath.OpenText()
        Do While sr.Peek() >= 0
            fctb.Text = sr.ReadLine()
        Loop
        sr.Close()
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'maketab()
        Label1.Text = System.IO.Path.GetFullPath(tcTop.ActiveTabPage.Text)
    End Sub
End Class

The "ActivePageChange" keeps giving me a "The path is not of a legal form." error!
I know there are other errors but I'm still learning on my own!
Can anyone help please?

Viewing all articles
Browse latest Browse all 27203

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>