Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Ctrl + B in RichtextBox

Ctrl + B in RichtextBox

Scheduled Pinned Locked Moved C#
question
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AB7771
    wrote on last edited by
    #1

    I want to set the font style to Bold when the user clicks Control + B key combination, How do i do that? Thanks & Regards, Pramod

    L 1 Reply Last reply
    0
    • A AB7771

      I want to set the font style to Bold when the user clicks Control + B key combination, How do i do that? Thanks & Regards, Pramod

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      private void richTextBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
      {
      if(e.KeyCode == Keys.B && e.Modifiers == Keys.Control)
      {
      this.richTextBox1.SelectionFont = new Font("Microsoft Sans Serif", 8, FontStyle.Bold);
      }
      }

      A 2 Replies Last reply
      0
      • L Lost User

        private void richTextBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
        if(e.KeyCode == Keys.B && e.Modifiers == Keys.Control)
        {
        this.richTextBox1.SelectionFont = new Font("Microsoft Sans Serif", 8, FontStyle.Bold);
        }
        }

        A Offline
        A Offline
        AB7771
        wrote on last edited by
        #3

        Thanks

        E 1 Reply Last reply
        0
        • A AB7771

          Thanks

          E Offline
          E Offline
          Empires
          wrote on last edited by
          #4

          You could also maintain the font and do it like this: if (e.KeyCode == Keys.B && e.Control) { richTextBox1.SelectionFont = new Font( richTextBox1.SelectionFont, richTextBox1.SelectionFont.Style ^ FontStyle.Bold ); e.Handled = true; }

          Michael Francik Empireland, Inc.

          A 1 Reply Last reply
          0
          • L Lost User

            private void richTextBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
            {
            if(e.KeyCode == Keys.B && e.Modifiers == Keys.Control)
            {
            this.richTextBox1.SelectionFont = new Font("Microsoft Sans Serif", 8, FontStyle.Bold);
            }
            }

            A Offline
            A Offline
            AB7771
            wrote on last edited by
            #5

            Thanks for that can also tell me how can i insert a link to a Folder in a richtext box. Pramod

            L 1 Reply Last reply
            0
            • E Empires

              You could also maintain the font and do it like this: if (e.KeyCode == Keys.B && e.Control) { richTextBox1.SelectionFont = new Font( richTextBox1.SelectionFont, richTextBox1.SelectionFont.Style ^ FontStyle.Bold ); e.Handled = true; }

              Michael Francik Empireland, Inc.

              A Offline
              A Offline
              AB7771
              wrote on last edited by
              #6

              Everything is fine but when i press Ctrl + I the cursor moves one tab ahead, Why does this happen? is Ctrl + I any pre-defined short cut for richtextbox. i am working in VS 2005. Thanks, Pramod

              1 Reply Last reply
              0
              • A AB7771

                Thanks for that can also tell me how can i insert a link to a Folder in a richtext box. Pramod

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                See this: http://msdn2.microsoft.com/en-us/library/f591a55w.aspx

                A 1 Reply Last reply
                0
                • L Lost User

                  See this: http://msdn2.microsoft.com/en-us/library/f591a55w.aspx

                  A Offline
                  A Offline
                  AB7771
                  wrote on last edited by
                  #8

                  i tried but when i set a link as http://microsoft.com the text display should be only microsoft.com , but the text displayed is http://microsoft.com please suggest Any other way to solve this. Thanks, Pramod

                  L 1 Reply Last reply
                  0
                  • A AB7771

                    i tried but when i set a link as http://microsoft.com the text display should be only microsoft.com , but the text displayed is http://microsoft.com please suggest Any other way to solve this. Thanks, Pramod

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    For example, if you want to open Directory c:\ then use file:\\c:\ or if you want to open d:\temp then use file:\\d:\temp

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups