Results 1 to 17 of 17

Thread: [RESOLVED] [2005] need help with user control

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    Resolved [RESOLVED] [2005] need help with user control

    hi all,

    i created a user control for a datetimetextbox. i used a textbox to hold the value. now i'm having a problem as to how i can add a Text property and also add this into the DataBindings Property.

    thanks.

    VB Version: Microsoft Visual Studio 2008 Professional Edition
    .NET Version: Microsoft .NET Framework Version 3.5
    OS: Windows XP SP3

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] need help with user control

    You can't add a Text property because Text is inherited from the Control class, so your UserControl already has a Text property. Think of a different name.

    Why have you created a UserControl anyway? If all you want is a TextBox then why not inherit the TextBox class? If you want more functionality then does the DateTimePicker control not already provide that?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    Re: [2005] need help with user control

    hi,

    i don't see the text property of my user control on the properties window. how do i make use of it? it's also not in the databindings collection property.

    i'm trying to create a datetimetextbox that accepts null values unlike the datetimepicker.

    i also checked the quantum software solution which i found on one of your threads. but when i checked the site, one of the prerequisites was .Net 1.1 and i don't think my client will want to have .Net 1.1 installed. i'm currently using .Net 2.0.

    thanks

    VB Version: Microsoft Visual Studio 2008 Professional Edition
    .NET Version: Microsoft .NET Framework Version 3.5
    OS: Windows XP SP3

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] need help with user control

    Quote Originally Posted by adshocker
    hi,

    i don't see the text property of my user control on the properties window. how do i make use of it? it's also not in the databindings collection property.

    i'm trying to create a datetimetextbox that accepts null values unlike the datetimepicker.

    i also checked the quantum software solution which i found on one of your threads. but when i checked the site, one of the prerequisites was .Net 1.1 and i don't think my client will want to have .Net 1.1 installed. i'm currently using .Net 2.0.

    thanks
    The original version of WFC was built on .NET 1.1. The last version that I saw on their site was .NET 2.0, which will also work for .NET 3.0 and 3.5 apps. They just haven't updated the web site text properly.

    The QSS control was a customised DateTimePicker, not a customised TextBox or UserControl.

    If you check the VB.NET CodeBank you'll see that I've posted a nullable DTP control there. I created that before QSS released the .NET 2.0 version of WFC but, after I did some more testing, I discovered there was a bug. Once QSS released WFC for .NET 2.0 I didn't bother trying to fix it. You should either use QSS WFC for .NET 2.0 or else use my code as a starting point for creating your own customised DateTimePicker the "right" way.

    Note that I created mine in the same way that QSS created their original version but made some modifications to get around an issue that arose out of a difference between how .NET 1.1 and .NET 2.0 handled certain Windows messages. It seemed to work and certainly did overcome that issue but, as I said, I found another.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] need help with user control

    Actually, I just took a look at the page for QSS WFC and it specifically says .NET 2.0.

    http://www.quantumsoftware.com.au/Pr...omponents.aspx

    The download page says you need .NET 1.1 but that's obviously an oversight on the part of their web designers.

    http://www.quantumsoftware.com.au/Do...s/Default.aspx
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] need help with user control

    Just for interests sake, QSS are located about an hour from where I live, which I didn't know when I first found that WFC library on the web. I was just looking for a WinForms data repeater control and there's was the only freebie. Of course, MS have finally created their own but it took a while, plus WFC has other good stuff in it.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    Re: [2005] need help with user control

    ok... thanks.

    VB Version: Microsoft Visual Studio 2008 Professional Edition
    .NET Version: Microsoft .NET Framework Version 3.5
    OS: Windows XP SP3

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    Re: [2005] need help with user control

    hi,

    need to ask in case i needed to create another user control.

    how do i add a property to the databindings property?

    thanks.

    VB Version: Microsoft Visual Studio 2008 Professional Edition
    .NET Version: Microsoft .NET Framework Version 3.5
    OS: Windows XP SP3

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] need help with user control

    You call DataBindings.Add on the control. The first argument is the name of the control property to bind to.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    Re: [2005] need help with user control

    thanks..

    one more thing.. how about the Text property issue i mentioned in my earlier post. how come it doesn't appear on the properties window when i use the control?

    VB Version: Microsoft Visual Studio 2008 Professional Edition
    .NET Version: Microsoft .NET Framework Version 3.5
    OS: Windows XP SP3

  11. #11
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,051

    Re: [2005] need help with user control

    If it's a composite control that you wrote, it's because you didn't expose a property that wraps the Text property of the TextBox contained in your user control.

  12. #12
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,051

    Re: [2005] need help with user control

    http://msdn.microsoft.com/en-us/libr...c2(VS.71).aspx

    Just poke around in MSDN until you discover what you are looking for.

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    Re: [2005] need help with user control

    Quote Originally Posted by FourBlades
    http://msdn.microsoft.com/en-us/libr...c2(VS.71).aspx

    Just poke around in MSDN until you discover what you are looking for.
    hi,

    i'm still not able to expose the Text property of the UserControl. i've read the article on the link you provided but i didn't see any samples on how to do this as well as on how to add the Text property to the DataBindings property of the control at design time.

    thanks

    VB Version: Microsoft Visual Studio 2008 Professional Edition
    .NET Version: Microsoft .NET Framework Version 3.5
    OS: Windows XP SP3

  14. #14
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] need help with user control

    You shouldn't be using the Text property of the UserControl at all. Add your own property and bind to that. Inside that property you can get and set the Text property of the TextBox.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    Re: [2005] need help with user control

    thanks...

    one more thing... when i add my usercontrol to my toolbox it looks like a wheel or something... is there any way i can use my own image for it?

    thanks

    VB Version: Microsoft Visual Studio 2008 Professional Edition
    .NET Version: Microsoft .NET Framework Version 3.5
    OS: Windows XP SP3

  16. #16
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] need help with user control

    Quote Originally Posted by adshocker
    when i add my usercontrol to my toolbox it looks like a wheel or something... is there any way i can use my own image for it?
    You can apply the ToolboxBitmap attribute to your class.

    http://msdn.microsoft.com/en-us/libr...attribute.aspx
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  17. #17

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    Re: [2005] need help with user control

    this is great! thanks.

    VB Version: Microsoft Visual Studio 2008 Professional Edition
    .NET Version: Microsoft .NET Framework Version 3.5
    OS: Windows XP SP3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width