none
RichTextBox always active (EDITED)

    Question

  • Hi people
    I'm not quite sure how to explain this but here goes....

    I am building (well trying anyway) a code editor using a split panel container...
    Panel1 (left hand side menu) and Panel 2 the main coding window.

    In the Menu panel i have all the objects available for the user so that when they click on something it will pull the info/code from that element and then place it into the main coding window, (EDITING THIS PART: my issue is that when the object is clicked it places the code snippet at the end of existing code whereas i need it to be placed on the same line where the user last clicked in the main coding window.) To this:

    In fact i have just discovered that my initial thoughts were wrong, here is the real problem.....
    When i try to add a new snippet of code by hitting that particular LABEL/button it replaces everything in the main window RTB whereas i want it to add the new snippet where the user last typed.

    I also forgot to mention that theses snippets are pulled from individual text file from My.Resources. using WinForms

    I am guessing that my buttons are missing something and are too basic in their coding, even if they do work :-)

    Label/button code

        Private Sub Label1Level10_Click(sender As Object, e As EventArgs) Handles Label1Level10.Click
            RTBox.Text = My.Resources.Map1
        End Sub

    Maybe i have explained myself a little better!?

    I can do it the other way round where the user clicks the object and it copies the code and then paste the snippet where the user clicks on the main coding window. This is not practical because i need the user to be able to just hit the return button when coding to create a new line and then just click the object he/she wants to add.

    If anyone understands that then great, please can you help? If not please say so and i will try to be a bit more explicit.

    Thanks in advance


    regards Flatland France




    • Edited by EyeMan Android Wednesday, July 27, 2016 10:08 AM Making everything as clear as possible
    Tuesday, July 26, 2016 4:14 PM

Answers

  • If you want to insert the text at the cursor position, then try this:

        RTBox.SelectedText = My.Resources.Map1

    In order to insert the text at new line, try:

        RTBox.SelectedText = VbCrLf & My.Resources.Map1 & vbCrLf

    If needed, you can exclude vbCrLf if the current line is empty.

    This will also replace (remove) the block of text which is currently selected, if any. In order to keep it, try ‘RTBox.SelectionLength = 0’ before inserting the snippet.

    • Marked as answer by EyeMan Android Wednesday, July 27, 2016 10:54 AM
    Wednesday, July 27, 2016 10:29 AM

All replies

  • Hi FlatlandFrance,

    Thank you for your post.

    To have a better understanding of your problem, could you please tell us what is your code editor project type? Winform, WPF or VSX.

    In addition, I suggest could offer some screenshot, you could ask for a requirement in the following link to verify your account:

    https://social.msdn.microsoft.com/Forums/en-US/a0fb057f-74d7-428c-9af0-bcf0c23299f1/verify-your-account-35?forum=reportabug

    After you express more detailed information about this, I will help you move to the direct forum for dedicated support.

    Thank you for your understanding.

    Best Regards, 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

    Click HERE to participate the survey.

    Wednesday, July 27, 2016 6:31 AM
    Moderator
  • Hi Lana Xu,
    and thanks for the reply, like i mentioned i wasn't sure how to explain and yes screenshots would make life easier, i will request a verification.

    By the way, i am using windows forms.

    thanks


    regards Flatland France

    Wednesday, July 27, 2016 9:02 AM
  • Your code is correctly replacing the whole text of the RTB.

    You need to use:

    Private Sub Label1Level10_Click(sender As Object, e As EventArgs) Handles Label1Level10.Click
            RTBox.AppendText( My.Resources.Map1 & VbCrLf) 'the crlf is the line feed...
        End Sub

    Wednesday, July 27, 2016 10:28 AM
  • If you want to insert the text at the cursor position, then try this:

        RTBox.SelectedText = My.Resources.Map1

    In order to insert the text at new line, try:

        RTBox.SelectedText = VbCrLf & My.Resources.Map1 & vbCrLf

    If needed, you can exclude vbCrLf if the current line is empty.

    This will also replace (remove) the block of text which is currently selected, if any. In order to keep it, try ‘RTBox.SelectionLength = 0’ before inserting the snippet.

    • Marked as answer by EyeMan Android Wednesday, July 27, 2016 10:54 AM
    Wednesday, July 27, 2016 10:29 AM
  • If you want to insert the text at the cursor position, then try this:

        RTBox.SelectedText = My.Resources.Map1

    In order to insert the text at new line, try:

        RTBox.SelectedText = VbCrLf & My.Resources.Map1 & vbCrLf

    If needed, you can exclude vbCrLf if the current line is empty.

    This will also replace (remove) the block of text which is currently selected, if any. In order to keep it, try ‘RTBox.SelectionLength = 0’ before inserting the snippet.

    Excellent that did the trick, big thumbs up :-)

    Thank you Viorel_


    regards Flatland France

    Wednesday, July 27, 2016 10:56 AM