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. extended textbox with button

extended textbox with button

Scheduled Pinned Locked Moved C#
help
5 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.
  • T Offline
    T Offline
    tabstop
    wrote on last edited by
    #1

    Hello, I want to create a control like a textbox additionally with a button inside. So i created a new class with base class TextBox. I wrote code into the constructor to create dynamically the button and position ist right-aligned. This works fine but the problem is that longer text is hidden behind the button. Is there any solution for this. Using usercontrols is no solution because the new control should look as a textbox with all his properties and methods.

    J 1 Reply Last reply
    0
    • T tabstop

      Hello, I want to create a control like a textbox additionally with a button inside. So i created a new class with base class TextBox. I wrote code into the constructor to create dynamically the button and position ist right-aligned. This works fine but the problem is that longer text is hidden behind the button. Is there any solution for this. Using usercontrols is no solution because the new control should look as a textbox with all his properties and methods.

      J Offline
      J Offline
      J4amieC
      wrote on last edited by
      #2

      tabstop wrote:

      Is there any solution for this.

      Of course there is, place the button to the side of the textbox rather than over it!

      tabstop wrote:

      Using usercontrols is no solution because the new control should look as a textbox with all his properties and methods.

      Thats a no-brainer. A usercontrol could have a textbox and button and then just wrap each property/method you would want and pass them through to the textbox. for example (in the UserControl):

      public string Text
      {
      get{ return this.textBox.Text; }
      set{ this.textBox.Text = value; }
      }

      --- How to get answers to your questions[^]

      L T 2 Replies Last reply
      0
      • J J4amieC

        tabstop wrote:

        Is there any solution for this.

        Of course there is, place the button to the side of the textbox rather than over it!

        tabstop wrote:

        Using usercontrols is no solution because the new control should look as a textbox with all his properties and methods.

        Thats a no-brainer. A usercontrol could have a textbox and button and then just wrap each property/method you would want and pass them through to the textbox. for example (in the UserControl):

        public string Text
        {
        get{ return this.textBox.Text; }
        set{ this.textBox.Text = value; }
        }

        --- How to get answers to your questions[^]

        L Offline
        L Offline
        led mike
        wrote on last edited by
        #3

        Or you could just expose the TextBox directly. Not good practice but I already question the value/validity of a button in a TextBox

        T 1 Reply Last reply
        0
        • L led mike

          Or you could just expose the TextBox directly. Not good practice but I already question the value/validity of a button in a TextBox

          T Offline
          T Offline
          tabstop
          wrote on last edited by
          #4

          Think about inputing a filename. You can enter the name directly or you can open another dialog to choose a filename. The button has the function to open another dialog depending of the context. The combobox has also the button inside. We want to use these controls with normal textboxes, comboboxes and others together on one form. The alignment, the look and feel must be same for all controls. (Also the big boss has decided it.)

          1 Reply Last reply
          0
          • J J4amieC

            tabstop wrote:

            Is there any solution for this.

            Of course there is, place the button to the side of the textbox rather than over it!

            tabstop wrote:

            Using usercontrols is no solution because the new control should look as a textbox with all his properties and methods.

            Thats a no-brainer. A usercontrol could have a textbox and button and then just wrap each property/method you would want and pass them through to the textbox. for example (in the UserControl):

            public string Text
            {
            get{ return this.textBox.Text; }
            set{ this.textBox.Text = value; }
            }

            --- How to get answers to your questions[^]

            T Offline
            T Offline
            tabstop
            wrote on last edited by
            #5

            thank you for your answer. i decided to use a usercontrol. There is one difficulty. The button must be inside the textbox and the entered text mustn't hidden by the button. How to combine controls, that the result looks like one textbox with described features.

            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