RichTextBox Label URL?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JZ

    RichTextBox Label URL?

    Hi,

    I remember reading sometime ago that is possible to create a RichtextBox
    label.

    Has anyone got any source or a URL.

    I'm looking for improvements on just setting ReadOnly = true or Enabled =
    false.
    Something which hides the caret / selection character.

    Help!!!!!!!!!!! !!!!!!!!

    --
    JZ


  • Imran Koradia

    #2
    Re: RichTextBox Label URL?

    If you simply want to hide the caret, here's a link:


    hope this helps..
    Imran.

    "JZ" <jj@anon.anon.c om> wrote in message
    news:413f4cb4$0 $29907$cc9e4d1f @news.dial.pipe x.com...[color=blue]
    > Hi,
    >
    > I remember reading sometime ago that is possible to create a RichtextBox
    > label.
    >
    > Has anyone got any source or a URL.
    >
    > I'm looking for improvements on just setting ReadOnly = true or Enabled =
    > false.
    > Something which hides the caret / selection character.
    >
    > Help!!!!!!!!!!! !!!!!!!!
    >
    > --
    > JZ
    >
    >[/color]


    Comment

    • JZ

      #3
      Re: RichTextBox Label URL?

      Yeah I'd seen that, I've tried various events but it still shows selection.

      Private Sub Form1_Load(ByVa l sender As Object, ByVal e As
      System.EventArg s) Handles MyBase.Load
      HideCaret(Me.Ri chTextBox1.Hand le)
      End Sub
      Private Sub RichTextBox1_En ter(ByVal sender As Object, ByVal e As
      System.EventArg s) Handles RichTextBox1.En ter
      HideCaret(Me.Ri chTextBox1.Hand le)
      End Sub
      Private Sub RichTextBox1_Mo useDown(ByVal sender As Object, ByVal e As
      System.Windows. Forms.MouseEven tArgs) Handles RichTextBox1.Mo useDown
      HideCaret(Me.Ri chTextBox1.Hand le)
      End Sub
      Private Sub RichTextBox1_Mo useEnter(ByVal sender As Object, ByVal e As
      System.EventArg s) Handles RichTextBox1.Mo useEnter
      HideCaret(Me.Ri chTextBox1.Hand le)
      End Sub
      Private Sub RichTextBox1_Se lectionChanged( ByVal sender As Object, ByVal
      e As System.EventArg s) Handles RichTextBox1.Se lectionChanged
      RichTextBox1.Se lectionStart = 0
      RichTextBox1.Se lectionLength = 0
      HideCaret(Me.Ri chTextBox1.Hand le)
      End Sub
      Private Sub RichTextBox1_Mo useUp(ByVal sender As Object, ByVal e As
      System.Windows. Forms.MouseEven tArgs) Handles RichTextBox1.Mo useUp
      HideCaret(Me.Ri chTextBox1.Hand le)
      End Sub

      Any further advice?

      --
      JZ


      Comment

      • Imran Koradia

        #4
        Re: RichTextBox Label URL?

        try these:
        Get detailed answers to common queries about Syncfusion Windows Forms components covering installation, features, licensing, and developer support.


        Get detailed answers to common queries about Syncfusion Windows Forms components covering installation, features, licensing, and developer support.


        hope that helps..
        Imran.

        "JZ" <jj@anon.anon.c om> wrote in message
        news:413f65cd$0 $29953$cc9e4d1f @news.dial.pipe x.com...[color=blue]
        > Yeah I'd seen that, I've tried various events but it still shows[/color]
        selection.[color=blue]
        >
        > Private Sub Form1_Load(ByVa l sender As Object, ByVal e As
        > System.EventArg s) Handles MyBase.Load
        > HideCaret(Me.Ri chTextBox1.Hand le)
        > End Sub
        > Private Sub RichTextBox1_En ter(ByVal sender As Object, ByVal e As
        > System.EventArg s) Handles RichTextBox1.En ter
        > HideCaret(Me.Ri chTextBox1.Hand le)
        > End Sub
        > Private Sub RichTextBox1_Mo useDown(ByVal sender As Object, ByVal e As
        > System.Windows. Forms.MouseEven tArgs) Handles RichTextBox1.Mo useDown
        > HideCaret(Me.Ri chTextBox1.Hand le)
        > End Sub
        > Private Sub RichTextBox1_Mo useEnter(ByVal sender As Object, ByVal e As
        > System.EventArg s) Handles RichTextBox1.Mo useEnter
        > HideCaret(Me.Ri chTextBox1.Hand le)
        > End Sub
        > Private Sub RichTextBox1_Se lectionChanged( ByVal sender As Object,[/color]
        ByVal[color=blue]
        > e As System.EventArg s) Handles RichTextBox1.Se lectionChanged
        > RichTextBox1.Se lectionStart = 0
        > RichTextBox1.Se lectionLength = 0
        > HideCaret(Me.Ri chTextBox1.Hand le)
        > End Sub
        > Private Sub RichTextBox1_Mo useUp(ByVal sender As Object, ByVal e As
        > System.Windows. Forms.MouseEven tArgs) Handles RichTextBox1.Mo useUp
        > HideCaret(Me.Ri chTextBox1.Hand le)
        > End Sub
        >
        > Any further advice?
        >
        > --
        > JZ
        >
        >[/color]


        Comment

        • JZ

          #5
          Re: RichTextBox Label URL?

          Hi,

          Well I think a combination of
          '--------
          Protected Overrides Sub WndProc(ByRef m As System.Windows. Forms.Message)
          ' WM_NCLBUTTONDOW N WM_LBUTTONDOWN
          If Me.ReadOnly AndAlso (m.Msg = &HA1 OrElse m.Msg = &H201) Then
          Console.WriteLi ne("ignored")
          Return 'ignore it
          End If
          MyBase.WndProc( m)
          End Sub 'WndProc
          '--------
          And
          '--------
          HideCaret(Me.Ri chTextBox1.Hand le)
          '--------

          Should do it, but I haven't quite figured it out yet.
          Its late in the UK, I'll work on it tomorrow.

          Thanks,

          --
          JZ
          "Imran Koradia" <nospam@microso ft.com> wrote in message
          news:Ob%23p3Eel EHA.948@TK2MSFT NGP12.phx.gbl.. .[color=blue]
          > try these:
          > http://www.syncfusion.com/FAQ/WinFor...c94c.asp#q949q
          >
          > http://www.syncfusion.com/FAQ/WinFor...c94c.asp#q866q
          >
          > hope that helps..
          > Imran.
          >
          > "JZ" <jj@anon.anon.c om> wrote in message
          > news:413f65cd$0 $29953$cc9e4d1f @news.dial.pipe x.com...[color=green]
          > > Yeah I'd seen that, I've tried various events but it still shows[/color]
          > selection.[color=green]
          > >
          > > Private Sub Form1_Load(ByVa l sender As Object, ByVal e As
          > > System.EventArg s) Handles MyBase.Load
          > > HideCaret(Me.Ri chTextBox1.Hand le)
          > > End Sub
          > > Private Sub RichTextBox1_En ter(ByVal sender As Object, ByVal e As
          > > System.EventArg s) Handles RichTextBox1.En ter
          > > HideCaret(Me.Ri chTextBox1.Hand le)
          > > End Sub
          > > Private Sub RichTextBox1_Mo useDown(ByVal sender As Object, ByVal e[/color][/color]
          As[color=blue][color=green]
          > > System.Windows. Forms.MouseEven tArgs) Handles RichTextBox1.Mo useDown
          > > HideCaret(Me.Ri chTextBox1.Hand le)
          > > End Sub
          > > Private Sub RichTextBox1_Mo useEnter(ByVal sender As Object, ByVal e[/color][/color]
          As[color=blue][color=green]
          > > System.EventArg s) Handles RichTextBox1.Mo useEnter
          > > HideCaret(Me.Ri chTextBox1.Hand le)
          > > End Sub
          > > Private Sub RichTextBox1_Se lectionChanged( ByVal sender As Object,[/color]
          > ByVal[color=green]
          > > e As System.EventArg s) Handles RichTextBox1.Se lectionChanged
          > > RichTextBox1.Se lectionStart = 0
          > > RichTextBox1.Se lectionLength = 0
          > > HideCaret(Me.Ri chTextBox1.Hand le)
          > > End Sub
          > > Private Sub RichTextBox1_Mo useUp(ByVal sender As Object, ByVal e As
          > > System.Windows. Forms.MouseEven tArgs) Handles RichTextBox1.Mo useUp
          > > HideCaret(Me.Ri chTextBox1.Hand le)
          > > End Sub
          > >
          > > Any further advice?
          > >
          > > --
          > > JZ
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • thomas wenning

            #6
            Re: RichTextBox Label URL?

            Hi JZ,


            use this http://www.codeproject.com/vb/net/rtflabelcp.asp

            Greeting

            Thomas

            "JZ" <jj@anon.anon.c om> schrieb im Newsbeitrag
            news:413f4cb4$0 $29907$cc9e4d1f @news.dial.pipe x.com...[color=blue]
            > Hi,
            >
            > I remember reading sometime ago that is possible to create a RichtextBox
            > label.
            >
            > Has anyone got any source or a URL.
            >
            > I'm looking for improvements on just setting ReadOnly = true or Enabled =
            > false.
            > Something which hides the caret / selection character.
            >
            > Help!!!!!!!!!!! !!!!!!!!
            >
            > --
            > JZ
            >
            >[/color]


            Comment

            • JZ

              #7
              Re: RichTextBox Label URL?

              That still shows the selected text, not really a label!

              --
              JZ


              Comment

              • JZ

                #8
                Re: RichTextBox Label URL?

                Hi,

                I have come up with a solution, its not 100% but I think its as good as I'm
                going to get it.
                If you click and move your mouse over the label from start to finish you get
                a little flicker.
                But apart from that it works, you can still use URLs too.

                Well just in case anyone is reading this in the future here's to code....

                Imports System.Windows. Forms
                Imports System.Componen tModel

                Public Class ReadOnlyRichTex tBox
                Inherits RichTextBox

                Private Declare Auto Function HideCaret Lib "user32.dll " (ByVal hwnd As
                IntPtr) As Int32

                Protected Overrides Sub OnGotFocus(ByVa l e As EventArgs)
                HideCaret(Me.Ha ndle)
                End Sub

                Protected Overrides Sub OnEnter(ByVal e As EventArgs)
                HideCaret(Me.Ha ndle)
                End Sub

                <DefaultValue(T rue)> Public Shadows Property [ReadOnly]() As Boolean
                Get
                Return True
                End Get
                Set(ByVal Value As Boolean)
                End Set
                End Property

                <DefaultValue(F alse)> Public Shadows Property TabStop() As Boolean
                Get
                Return False
                End Get
                Set(ByVal Value As Boolean)
                End Set
                End Property

                Public Sub New()
                MyBase.ReadOnly = True
                MyBase.TabStop = False
                Me.SetStyle(Con trolStyles.Sele ctable, False)
                HideCaret(Me.Ha ndle)
                End Sub

                Private Sub ReadOnlyRichTex tBox_SelectionC hanged(ByVal sender As Object,
                ByVal e As System.EventArg s) Handles MyBase.Selectio nChanged
                Me.SelectionLen gth = 0
                HideCaret(Me.Ha ndle)
                End Sub

                Private Sub ReadOnlyRichTex tBox_MouseDown( ByVal sender As Object, ByVal e As
                System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseDow n
                HideCaret(Me.Ha ndle)
                End Sub

                Private Sub ReadOnlyRichTex tBox_MouseUp(By Val sender As Object, ByVal e As
                System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseUp
                HideCaret(Me.Ha ndle)
                End Sub

                End Class

                If anyone improves on that please post in here, even months ahead.

                --
                JZ


                Comment

                • JZ

                  #9
                  Re: RichTextBox Label URL?

                  In fact if you don't need to use URLs then you can add.

                  Protected Overrides Sub WndProc(ByRef m As System.Windows. Forms.Message)
                  ' WM_NCLBUTTONDOW N WM_LBUTTONDOWN
                  If Me.ReadOnly AndAlso (m.Msg = &HA1 OrElse m.Msg = &H201) Then
                  Console.WriteLi ne("ignored")
                  Return 'ignore it
                  End If

                  MyBase.WndProc( m)
                  End Sub 'WndProc

                  I also forgot to mention that you'd need to change the borderstyle to none
                  and the background color.

                  --
                  JZ


                  Comment

                  Working...