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 / Windows Forms / WinForm Controls / January 2007

Tip: Looking for answers? Try searching our database.

ToolStripControlHost, ToolStripDateTimePicker and ApplicationSettings

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kevin - 23 Jan 2007 11:09 GMT
Hi All
I have created a ToolStripDateTimePicker with the following code:

Public Class ToolStripDateTimePicker
   Inherits ToolStripControlHost
   Public Event ValueChanged(ByVal sender As Object, ByVal e As
EventArgs)
   Sub New()
       MyBase.new(New DateTimePicker)
       AddHandler Me.DateTimePicker.ValueChanged, AddressOf
ValueChanged_Handler
   End Sub
   Private Sub ValueChanged_Handler(ByVal sender As Object, ByVal e As
EventArgs)
       RaiseEvent ValueChanged(sender, e)
   End Sub

   Public ReadOnly Property DateTimePicker() As DateTimePicker
       Get
           Return DirectCast(MyBase.Control, DateTimePicker)
       End Get
   End Property

   Public Property Value() As Date
       Get
           Return DirectCast(MyBase.Control, DateTimePicker).Value
       End Get
       Set(ByVal value As Date)
           DirectCast(MyBase.Control, DateTimePicker).Value = value
       End Set
   End Property

End Class

This all works fine except I am unable to use the ApplicationSettings
feature of Visual Studio 2005/.Net 2.0.
I have created a form, and added a ToolStrip to it.  I then added my
ToolStripDateTimePicker to it (had to do this by adding a
ToolStripTextbox and then changing its type as it wasnt available from
the list).
I then click on the ToolStripDateTimePicker and Select
Data->(Application Settings)->(PropertyBinding).  I then add the
binding to the Value property of the object.

However, when I change the value of the of the ToolStripDateTimePicker
it doesnt update the setting and subsequently doesnt save it when the
program exits. However if I update the setting, the
ToolStripDateTimePicker DOES update.  This makes me believe that
wrapping the DTP in the toolbar means I am missing an important event
that triggers the change of the setting when the value of the DTP
changes.

I know I can manually set the value of the setting to be the value of
the DTP which does work, but I'd rather find the proper solution.
Thanks in advance
Kevin
Kevin - 23 Jan 2007 11:13 GMT
Actually, changing the setting doesnt seem to update the DTP, sorry!
Kevin - 26 Jan 2007 13:58 GMT
Have done some more digging, I think I need to implement
IBindableComponent, but I havent done this yet so cant confirm it.

see "Application Settings for Windows Forms" in msdn help for details.
Kevin - 26 Jan 2007 15:15 GMT
I can confirm this is correct.  You should also implement
System.ComponentModel.INotifyPropertyChanged
and raise the event when the property you are binding on changes.

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.