Esempio n. 1
0
        //=====================================================================

        /// <summary>
        /// Load the grid with the specified calendar items
        /// </summary>
        private void LoadGridWithItems()
        {
            int gridIdx = dgvCalendar.CurrentCellAddress.Y;

            VCalendar.TimeZones.Sort(true);
            dgvCalendar.DataSource = null;

            // Get just the time zones used?
            if (chkLimitToCalendar.Checked)
            {
                // Get just the time zones used
                StringCollection timeZonesUsed = new StringCollection();

                if (vCal != null)
                {
                    vCal.TimeZonesUsed(timeZonesUsed);

                    // Remove entries that don't exist
                    for (int idx = 0; idx < timeZonesUsed.Count; idx++)
                    {
                        if (VCalendar.TimeZones[timeZonesUsed[idx]] == null)
                        {
                            timeZonesUsed.RemoveAt(idx);
                            idx--;
                        }
                    }
                }

                // Add each instance to a temporary collection and bind it to the grid
                timeZones.Clear();

                foreach (string timeZoneId in timeZonesUsed)
                {
                    timeZones.Add(VCalendar.TimeZones[timeZoneId]);
                }

                dgvCalendar.DataSource = timeZones;
            }
            else
            {
                dgvCalendar.DataSource = VCalendar.TimeZones;
            }

            // Enable or disable the buttons based on the vCard count
            btnEdit.Enabled = btnDelete.Enabled = (dgvCalendar.RowCount != 0);

            // Stay on the last item selected
            if (gridIdx > -1 && gridIdx < dgvCalendar.RowCount)
            {
                dgvCalendar.CurrentCell = dgvCalendar[0, gridIdx];
            }
        }