コード例 #1
0
ファイル: ListControlHelper.cs プロジェクト: xxdoc/SKS
 /// <summary>
 /// Updates the list of items data of the controls in runtime after the EndInit has been invoked.
 /// </summary>
 private void RefreshItemsData()
 {
     if (!DesignMode)
     {
         foreach (System.Windows.Forms.ListControl lstControl in ItemsData.Keys)
         {
             if (lstControl is System.Windows.Forms.ComboBox)
             {
                 for (int i = 0; (i < ((System.Windows.Forms.ComboBox)lstControl).Items.Count) && (i < ItemsData[lstControl].Length); i++)
                 {
                     //((System.Windows.Forms.ComboBox)lstControl).Items[i] = ItemsData[lstControl][i];
                 }
             }
             else
             {
                 for (int i = 0; (i < ((System.Windows.Forms.ListBox)lstControl).Items.Count) && (i < ItemsData[lstControl].Length); i++)
                 {
                     //((System.Windows.Forms.ListBox)lstControl).Items[i] = ItemsData[lstControl][i];
                 }
             }
         }
         ItemsData.Clear();
     }
 }
コード例 #2
0
        private void Navigate(PageChanges change)
        {
            int totalRecords;
            int newPageSize;

            if (PageContract == null)
            {
                return;
            }

            totalRecords = PageContract.GetTotalCount();
            newPageSize  = (int)cmbPageSizes.SelectedItem;

            if (totalRecords == 0)
            {
                ItemsData.Clear();
                TotalPages = 1;
                Page       = 1;
            }
            else
            {
                TotalPages = (totalRecords / newPageSize) + (int)((totalRecords % newPageSize == 0) ? 0 : 1);
            }

            int newPage = 1;

            switch (change)
            {
            case PageChanges.First:
                if (Page == 1)
                {
                    return;
                }
                break;

            case PageChanges.Previous:
                newPage = (Page - 1 > TotalPages) ? TotalPages : (Page - 1 < 1) ? 1 : Page - 1;
                break;

            case PageChanges.Current:
                newPage = (Page > TotalPages) ? TotalPages : (Page < 1) ? 1 : Page;
                break;

            case PageChanges.Next:
                newPage = (Page + 1 > TotalPages) ? TotalPages : Page + 1;
                //(Page + 1) < 1 ? 1 :
                break;

            case PageChanges.Last:
                if (Page == TotalPages)
                {
                    return;
                }
                newPage = TotalPages;
                break;

            default:
                break;
            }

            var startingIndex = (newPage - 1) * newPageSize;

            var oldPage = Page;

            RaisePreviewPageChange(Page, newPage);

            Page = newPage;
            ItemsData.Clear();

            ICollection <object> fetchData = PageContract.GetRecordsBy(startingIndex, newPageSize, Filter);

            foreach (object row in fetchData)
            {
                ItemsData.Add(row);
            }

            RaisePageChanged(oldPage, Page);
        }