ActiveReports Developers 7 Now Available in Beta!! (click for details)

SharpGrid Support

Started by MartinTeefy at 08-25-2009 9:53 AM. Topic has 5 replies.

Print Search Rate
Sort Posts:    
   08-25-2009, 9:53 AM
MartinTeefy is not online. Last active: 5/14/2011 12:33:49 AM MartinTeefy

Top 500 Posts
Joined on 09-26-2003
London
Posts 40
SharpGrid Calendar sample a day out?
Hi,

I need to create an appointment system and as part of my research found there was a VB6 calendar sample - great i thought but the results are wrong by a day.

Running the sample August is auto set but the 1st is set as Sunday and today the 25th
is shown as Wednesday not Tuesday!

The Mondays are shaded like the Sundays i.e. Week-ends are normally shiwn as SAT/SUN a different clour from work days.

Has any-body else noticed this and how can it be fixed. I'd like to use #grid as the entry point to the appointment sub-system.

Thanks
Martin


   Report 
   08-26-2009, 12:26 AM
Andrey - DD is not online. Last active: 8/25/2011 5:42:49 PM Andrey - DD

Top 25 Posts
Joined on 08-01-2007
Russia, Novosibirsk
Posts 671

DDStaff
Re: SharpGrid Calendar sample a day out?

Attachment: Calendar.zip

MartinTeefy,

You are experiencing this behaviour because this sample is adapted for USA Regional settings (i.e. Sunday is the first day of the week). So if you are using different regional settings and Monday is the first day of the week then Calendar sample will highlight Mondays and Sundays instead of Saturdays and Sundays and your order will be Monday,..., Sunday instead of Sunday,..,Saturday so days in month will be displayed incorrectly. In order to correct this we should add to DateDiff and Weekday functions inside this sample an optional parameter FirstDayOfWeek with System or Monday value. I've modified this sample so its become more universal, however you should highlight the weekends based on your current settings. Please see the attached sample.

Thank you,
Andrey T.


   Report 
   08-29-2009, 2:50 AM
MartinTeefy is not online. Last active: 5/14/2011 12:33:49 AM MartinTeefy

Top 500 Posts
Joined on 09-26-2003
London
Posts 40
Re: SharpGrid Calendar sample a day out?
Thanks for the modifications to the classmodule. It works fine now but I have another question.

I populate each day with the number of appointments but the grid click event only fire when the cell clicked is a heading i.e. Monday or Tuesday. Clicking on any real cell I cannot get it to fire.

Any ideas?

Thanks
   Report 
   08-30-2009, 10:31 PM
Andrey - DD is not online. Last active: 8/25/2011 5:42:49 PM Andrey - DD

Top 25 Posts
Joined on 08-01-2007
Russia, Novosibirsk
Posts 671

DDStaff
Re: SharpGrid Calendar sample a day out?
MartinTeefy,

You can use MouseDown or MouseUp events.

Thank you,
Andrey T.

   Report 
   09-01-2009, 9:06 AM
MartinTeefy is not online. Last active: 5/14/2011 12:33:49 AM MartinTeefy

Top 500 Posts
Joined on 09-26-2003
London
Posts 40
Re: SharpGrid Calendar sample a day out?
Hi,

I need a bit more help with this problem...

Using the mousedown/up event still does not entirely help.

Let me explain.

The calendar is drawn as you know via the IsgGridCustomDraw_DrawCell routine in the classmodule as per the earlier provided zip to provide an international safe version of the sample.

within this classmodule I access the database and create an array m_AppointmentsData to use along with your m_CalendarData array to hold the number of appointments per day of the current month in the form 4- Appts

        If m_AppointmentsData(CStr(m_CalendarData(weekdayNumber, weekNumber)) - 1, 1) <> "0" Then  ' No Appts for this day
            displayString = CStr(m_CalendarData(weekdayNumber, weekNumber)) & vbCrLf & vbCrLf & m_AppointmentsData(CStr(m_CalendarData(weekdayNumber, weekNumber)) - 1, 1)
        Else
            displayString = CStr(m_CalendarData(weekdayNumber, weekNumber))  ' This is the original daya number only
        End If

So back to the form routine MonthGrid_MouseDown the values are not all showing correctly:

    ' set the current cell
    MonthGrid.col = MonthGrid.MouseCol
    MonthGrid.row = MonthGrid.MouseRow
   
    nRow = MonthGrid.MouseRow
    nCol = MonthGrid.MouseCol
  
   ' ensure that the cell has a value
    If Len(MonthGrid.CurrentCell.Value) > 0 Then ' always blank
   
        MsgBox "Current Value is " & MonthGrid.CurrentCell.Value 
   
    Else
   
        nColkey = MonthGrid.CellAt(nRow, nCol).ColKey
        nRowkey = MonthGrid.CellAt(nRow, nCol).RowKey
       
        MsgBox MonthGrid.CellAt(nRow, nCol).ColKey
       
        MsgBox MonthGrid.cell(nRowkey, nColkey).Value
   
    End If

The selected cells have either the day value e.g. 13 or 14 & vbcrlf & 4 - Appts but although the mousedown code shows the correct row and column values, the actual value for the cell is always blank.

Am I missing something here and has it some-thing to do with the fact that the actual values are custom drawn onto the grid in the classmodule?

Any help or advice is much appreciated. I really need to get the event code to recognise if any appointments are present for a selected day e.g. if instr(1,monthgrid().???," - ") then

Thanks
Martin





   Report 
   09-01-2009, 11:32 PM
Andrey - DD is not online. Last active: 8/25/2011 5:42:49 PM Andrey - DD

Top 25 Posts
Joined on 08-01-2007
Russia, Novosibirsk
Posts 671

DDStaff
Re: SharpGrid Calendar sample a day out?

Attachment: Calendar2.zip
Martin,

You are experiencing this behaviour because custom drawn cell values are not exactly cell values, you should add your appointment data to cells using SGGrid1.Array or SGGrid1.Cell for example. I've attached a sample, run it and click any calendar cell to set value for this cell, then click this cell again and you'll get MsgBox with cell's value.

Thank you,
Andrey T.

   Report 
GrapeCity » Product Support » SharpGrid Suppo... » SharpGrid Calendar sample a day out?

Privacy Policy | Copyright © 1997-2012 — GrapeCity, inc.
All trademarks mentioned are the property of their respective owners.