Results 1 to 23 of 23

Thread: [RESOLVED] MonthCalendar problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Resolved [RESOLVED] MonthCalendar problem

    I have one more problem with MonthControl.

    I have For...Next hanger.

    And when I bold some dates the program doesn't show bold dates on month calendar.
    When I move on next or previous month and get back to currently month the program normal displays bold dates. What's the problem?

  2. #2
    Fanatic Member Seraph's Avatar
    Join Date
    Jul 2007
    Posts
    959

    Re: MonthCalendar problem

    You're not being very descriptive.

    Some code that generates the bold dates might help a bit.

    Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7

    SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
    [Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]

    [.NET and MySQL Quick Guide]

  3. #3
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: MonthCalendar problem

    What is "For...Next hanger"?

    As for the bolded dates problem, you need to call UpdateBoldedDates method after you add bolded date(s) to your MonthCalendar
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Re: MonthCalendar problem

    For...Next

    Dim a As Integer
    Dim b As Integer

    For a = 1 To b
    ...
    Next

  5. #5
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: MonthCalendar problem

    Quote Originally Posted by hepeci View Post
    For...Next

    Dim a As Integer
    Dim b As Integer

    For a = 1 To b
    ...
    Next
    So what is the problem with this loop? Your a and b variables are not initialized thus they get the default value of zero.
    In the For loop, you set a = 1, but b is still 0, so the loop never runs any iteration. If you want to loop backwards, you have to explicitly code it
    Code:
    For a = 1 to b Step -1
    ....
    Next
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  6. #6
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: MonthCalendar problem

    Based on what I am reading, when you add bolded dates, the control is not refreshing until you move months, is that correct?

    If so, did you try calling UpdateBoldedDates?

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Re: MonthCalendar problem

    Negative,thanks!

    And one more thing, how to check is some date bold?

  8. #8
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: MonthCalendar problem

    BoldedDates is an array of bolded dates. You could use the Contains method to determine if a specific date is bolded or not.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Re: MonthCalendar problem

    Actually I'm interested in how to check is selected date bold or not.

  10. #10
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: MonthCalendar problem

    So check to see if the BoldedDates contains the SelectionStart date.

  11. #11
    Fanatic Member Seraph's Avatar
    Join Date
    Jul 2007
    Posts
    959

    Re: MonthCalendar problem

    Just how Negative0 told you.

    Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7

    SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
    [Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]

    [.NET and MySQL Quick Guide]

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Re: MonthCalendar problem

    Code:
            lblDate.Text = MonthCalendar1.SelectionRange.Start
    That's code for printing selected dates, this goes on _DateChanged event of MonthCalendar control, and how to check bold dates, actually is selected date bold or not?

  13. #13
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: MonthCalendar problem

    I think this is what they have told you
    Code:
        Private Sub MonthCalendar1_DateChanged(ByVal sender As Object, _
                                               ByVal e As System.Windows.Forms.DateRangeEventArgs) _
                                               Handles MonthCalendar1.DateChanged
            If MonthCalendar1.BoldedDates.Contains(MonthCalendar1.SelectionStart) Then
                Stop
            End If
        End Sub
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Re: MonthCalendar problem

    This code doesn't work ('Contains' is not a member of 'System.Array')

  15. #15
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: MonthCalendar problem

    What version of the .Net Framework are you using?

  16. #16

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Re: MonthCalendar problem

    .NET Framework 2.0.50727

  17. #17
    Fanatic Member Seraph's Avatar
    Join Date
    Jul 2007
    Posts
    959

    Re: MonthCalendar problem

    Actually, your code will have to be something like this:

    Code:
            Dim boldDateList() As Date = MonthCalendar1.BoldedDates
    
            For Each d As Date In boldDateList
                If d.ToShortDateString = MonthCalendar1.SelectionStart.ToShortDateString Then
                    MessageBox.Show("True")
                End If
            Next
    I realized that BoldedDates returns the selected Date *with* the current time appended to the end. Therefore, trying to compare SelectionStart with a BoldedDate item won't work. The dates may match but the times won't. So, you have to be able to shorten the date to just the date, which is done above.

    Maybe there is a way to do it with BoldedDates, but I can't find one.

    Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7

    SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
    [Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]

    [.NET and MySQL Quick Guide]

  18. #18

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Re: MonthCalendar problem

    That's it. Thanks!

  19. #19
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: [RESOLVED] MonthCalendar problem

    That means that you did something like this
    Code:
            MonthCalendar1.AddBoldedDate(#12/19/2009 08:00#)
    instead of
    Code:
            MonthCalendar1.AddBoldedDate(#12/19/2009#)
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  20. #20
    Fanatic Member Seraph's Avatar
    Join Date
    Jul 2007
    Posts
    959

    Re: [RESOLVED] MonthCalendar problem

    Quote Originally Posted by dbasnett View Post
    That means that you did something like this
    Code:
            MonthCalendar1.AddBoldedDate(#12/19/2009 08:00#)
    instead of
    Code:
            MonthCalendar1.AddBoldedDate(#12/19/2009#)
    Well, true, I guess it depends on how you add the dates.
    I was doing it like this:

    Code:
    MonthCalendar1.AddBoldedDate(Now.AddDay(-4))
    MonthCalendar1.AddBoldedDate(Now())
    MonthCalendar1.AddBoldedDate(Now.AddDay(3))

    Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7

    SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
    [Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]

    [.NET and MySQL Quick Guide]

  21. #21
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: [RESOLVED] MonthCalendar problem

    If you would have added them like this you wouldn't have needed the additional code.

    Code:
            MonthCalendar1.AddBoldedDate(Now.AddDays(-4).Date)
            MonthCalendar1.AddBoldedDate(Now().Date)
            MonthCalendar1.AddBoldedDate(Now.AddDays(3).Date)
    
    
    
            If MonthCalendar1.BoldedDates.Contains(MonthCalendar1.SelectionStart.Date) Then
                Beep()
            End If
    So we worked around the OP's problem, but did we actually fix it?
    Last edited by dbasnett; Dec 16th, 2009 at 03:16 PM.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  22. #22
    Fanatic Member Seraph's Avatar
    Join Date
    Jul 2007
    Posts
    959

    Re: [RESOLVED] MonthCalendar problem

    I guess it depends on how he is adding his dates and where he is getting them from. lol

    Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7

    SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
    [Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]

    [.NET and MySQL Quick Guide]

  23. #23
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: [RESOLVED] MonthCalendar problem

    The OP never posted code for how the dates were being bolded. Well hopefully it is not one of those things that one wrong led to a kludge, that will lead to many more problems.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

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