jauno
  • jauno
  • Member Topic Starter
2015-10-22T18:55:05Z
Good evening!
I just bought iGrid for ActiveX and I would realize a calendar project in VB6.
I would like to let a user mark his holidays in a calendar with rows = days and columns = months by selecting cells.
But iGrid only allows multicell selection in a rectangle.
I am lookin for a way to select cells not rectangulary but "in a calendar way".
This means, if the user begins selection in a cell of a column (day of a month) and he changes to a new column (month) I would like to select automatically all cells under the starting cell of the old column (month) and select all cells above the ending cell of the new column.
How could I realize this?

place a iGrid in a vb form and name it grid

Dim GRows As Long
Private Function DaysInMonth(ByVal datum As Date) As Integer
  DaysInMonth = Format(DateSerial(Year(datum), Month(datum) + 1, 1 - 1), "Dd")
End Function

Private Sub Form_Initialize()
 GRows = 31
End Sub

Private Sub Form_Load()

  grid.Virtual = True
  
  For j = 2016 To 2017
    For m = 1 To 12
      mLong$ = Format$("1." + CStr(m) + "." + CStr(j), "mmmm")
      mShort$ = Format$("1." + CStr(m) + "." + CStr(j), "mmm")
      mNo$ = Format$("1." + CStr(m) + "." + CStr(j), "mm")
      grid.AddCol mNo$ + "-" + CStr(j), mShort$ + " " + CStr(j)
    Next m
  Next j
  grid.Clear
 
  
'
  For j = 2016 To 2017
    For m = 1 To 12
      dm = DaysInMonth("1." + CStr(m) + "." + CStr(j))
      For d = 1 To 31
        c = 12 * (j - 2016) + m
        r = d
        If d <= dm Then
          T$ = Format$(CStr(d) + "." + CStr(m) + "." + CStr(j), "ddd")
          T$ = Right$(" " + CStr(d), 2) + " " + T$
          grid.CellValue(r, c) = T$
          If Weekday(CStr(d) + "." + CStr(m) + "." + CStr(j), vbMonday) = 7 Then
            grid.CellForeColor(r, c) = &HC0&
            grid.CellBackColor(r, c) = &HE0E0E0
          ElseIf Weekday(CStr(d) + "." + CStr(m) + "." + CStr(j), vbMonday) = 6 Then
            grid.CellForeColor(r, c) = &HFF8080
            grid.CellBackColor(r, c) = &HF5F5F5
          End If
        Else
          grid.CellSelectable(r, c) = False
        End If
      Next d
    Next m
  Next j
'
  grid.SelectionAlphaBlend = 44
    
End Sub


Private Sub grid_RequestRow(ByVal lRow As Long, bNoMoreRows As Boolean)

 If lRow > GRows Then bNoMoreRows = True
 
End Sub
[/code]
Igor/10Tec
2015-10-23T07:46:37Z
When multiselection mode is on, iGrid allows you to select its cells in any combinations - not only rectangular blocks. We have an example of that in the iGrid CHM:

iGrid ActiveX MultiSelect.png

Click to View Image273 View(s)



The help file also contains the description of commands you can use in iGrid to select any blocks of cells.

As for coding, the CellSelected property also allows you to make any cell of iGrid selected. When the user changes the selection of a cell, the CellSelectionChange event is fired, and you can implement your custom selection logic based on the CellSelected property in this event.