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
  1. Home
  2. General Programming
  3. C#
  4. How to override the Text property of Control class?

How to override the Text property of Control class?

Scheduled Pinned Locked Moved C#
csharpvisual-studiotutorialquestion
2 Posts 2 Posters 2 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.
  • D Offline
    D Offline
    dreamwinter
    wrote on last edited by
    #1

    :confused:I create a UserControl and add a TextBox into the control.I want to have a Text property,in order that set or get the TextBox.Text.But I know Control class had the same property,and then I key the code that in list -------------------- public partial class UserControl1 : UserControl { string _t; [Browsable(true)] public override string Text { get { this.textBox1.Text = _t; return _t; } set { _t = value; this.textBox1.Text = _t; } ... } ----------------------------- When I test the control,I modify the Text property in the Properties Designer of the VS.NET 2005,The Control.Text get a value.But I open the method InitializeComponent() ,I can not find the code that initialize control.Text. So,When the test application running,The value that Text property of the TextBox in the control is lost. Can you tell me why? How to deal with it? Thanks a lot!

    L 1 Reply Last reply
    0
    • D dreamwinter

      :confused:I create a UserControl and add a TextBox into the control.I want to have a Text property,in order that set or get the TextBox.Text.But I know Control class had the same property,and then I key the code that in list -------------------- public partial class UserControl1 : UserControl { string _t; [Browsable(true)] public override string Text { get { this.textBox1.Text = _t; return _t; } set { _t = value; this.textBox1.Text = _t; } ... } ----------------------------- When I test the control,I modify the Text property in the Properties Designer of the VS.NET 2005,The Control.Text get a value.But I open the method InitializeComponent() ,I can not find the code that initialize control.Text. So,When the test application running,The value that Text property of the TextBox in the control is lost. Can you tell me why? How to deal with it? Thanks a lot!

      L Offline
      L Offline
      Libra
      wrote on last edited by
      #2

      I have the same problem as you say. If you know how to solve, tell me please. :((:((:(( === Game is power! ===

      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