Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / November 2007

Tip: Looking for answers? Try searching our database.

Property ... what am I doing wrong?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
shapper - 06 Nov 2007 16:35 GMT
Hello,

Let me explain it better. What I need is to make something like:

Dim mc as MyControl
mc.Value = "Hello"

This would create a MyControl instance and would set the TextBox.Text
= "Hello"

Then, I would need retrieve its value through the property on, for
example, a MyControl event:

Sub mc_CustomEvent(...) Handles mc.CustomEvent

 Dim s as string

 s = mc.Value

End Sub

Inside my custom control I have the property defined as follows:

   Private _Value As String
   Public Property Value() As String
     Get
       Return tbInput.Text
     End Get
     Set(ByVal value As String)
       _Value = value
     End Set
   End Property ' Value

And the TextBox is defined as follows:

   Private Sub tbInput_Init(ByVal sender As Object, ByVal e As
EventArgs) Handles tbInput.Init
     tbInput.Text = Me.Value
   End Sub

Both set and get are not working.

If I use the property as follows:

   Private _Value As String
   Public Property Value() As String
     Get
       Return _Value
     End Get
     Set(ByVal value As String)
       _Value = value
     End Set
   End Property ' Value

I am at least able to define the TextBox value.

What am I doing wrong?

Thanks,

Miguel
Roland Dick - 06 Nov 2007 22:22 GMT
Hi shapper,

shapper schrieb:
> Inside my custom control I have the property defined as follows:
>
[quoted text clipped - 16 lines]
>
> Both set and get are not working.

I think what's happening is that you're setting Value from the code
using your control after it has been initialized - so _Value has the
proper string, but nothing writes that string into tbInput.Text.

Unless you need it for something else, get rid of _Value, and read
from/write to tbInput.Text in your Get and Set accessor.

Hope this helps,

Roland

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.