예제 #1
0
        //给ShowCardDataSource赋值的时候调用此函数
        private void InitShowCard()
        {
            //先创建Card显示列
            if (string.IsNullOrEmpty(_CardColumn))
            {
                if (_showCardColumns != null && _showCardColumns.Length > 0)
                {
                    DataGridViewColumn[] columns = new DataGridViewColumn[_showCardColumns.Length];
                    for (int i = 0; i < _showCardColumns.Length; i++)
                    {
                        columns[i] = _showCardColumns[i];
                    }

                    cardDataGrid.textdataGrid.Columns.Clear();
                    cardDataGrid.textdataGrid.Columns.AddRange(columns);
                }
            }
            else
            {
                string[]             Columns = _CardColumn.Split(new char[] { ',' });
                DataGridViewColumn[] columns = new DataGridViewColumn[Columns.Length];
                for (int i = 0; i < columns.Length; i++)
                {
                    string[] pms = Columns[i].Split(new char[] { '|' });
                    columns[i]                  = new DataGridViewTextBoxColumn();
                    columns[i].Name             = "col" + pms[0];
                    columns[i].HeaderText       = pms[1];
                    columns[i].DataPropertyName = pms[0];
                    if (pms[2] == "auto")
                    {
                        columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    }
                    else
                    {
                        columns[i].Width = Convert.ToInt32(pms[2]);
                    }
                    columns[i].ReadOnly = true;
                    columns[i].SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
                    //columns[i].DefaultCellStyle = new DataGridViewCellStyle();
                }

                cardDataGrid.textdataGrid.Columns.Clear();
                cardDataGrid.textdataGrid.Columns.AddRange(columns);
            }


            cardDataGrid.textdataGrid.SeqVisible = _isShowSeq;


            if (PageNoChanged != null)
            {
                cardDataGrid.textpager.PageNoChanged += new PagerEventHandler(textpager_PageNoChanged);
            }

            cardDataGrid.textdataGrid.Click       += new EventHandler(textdataGrid_Click);
            cardDataGrid.textdataGrid.DoubleClick += new EventHandler(dgvSelectCard_DoubleClick);
            cardDataGrid.ClickLetter   += new EventHandler(cardDataGrid_ClickLetter);
            cardDataGrid.DeleteLetter  += new EventHandler(cardDataGrid_DeleteLetter);
            cardDataGrid.ConfirmLetter += new EventHandler(cardDataGrid_ConfirmLetter);
            cardDataGrid.CloseLetter   += new EventHandler(cardDataGrid_CloseLetter);



            cardDataGrid.letterpanel.Visible = IsShowLetter;
            if (IsShowPage == false)
            {
                cardDataGrid.textpager.pageSize = 200;
            }
            cardDataGrid.textpager.Visible    = IsShowPage;
            cardDataGrid.Width                = ShowCardWidth < this.Width ? this.Width : ShowCardWidth;
            cardDataGrid.Height               = ShowCardHeight < 200 ? 200 : ShowCardHeight;
            cardDataGrid.textpager.IsPage     = _isPage;
            cardDataGrid.textpager.DataSource = _source;
            cardDataGrid.DrawLetter();
            AddSelectCardToTopForm();
            cardDataGrid.Hide();
        }
예제 #2
0
        private void InitShowCard(int ColumnIndex,CardDataGrid cardDataGrid)
        {
            //if (PageNoChanged != null)
            //{
            //    cardDataGrid.textpager.PageNoChanged += new PagerEventHandler(textpager_PageNoChanged);
            //    cardDataGrid.textpager.pageNo = 1;
            //}

            cardDataGrid.textdataGrid.DoubleClick += new EventHandler(dgvSelectCard_DoubleClick);
            cardDataGrid.ClickLetter += new EventHandler(cardDataGrid_ClickLetter);
            cardDataGrid.DeleteLetter += new EventHandler(cardDataGrid_DeleteLetter);
            cardDataGrid.ConfirmLetter += new EventHandler(cardDataGrid_ConfirmLetter);
            cardDataGrid.CloseLetter += new EventHandler(cardDataGrid_CloseLetter);


            int cardIndex;
            if (ColumnIsBindSelectionCard(ColumnIndex,out cardIndex))
            {
                DataGridViewColumn[] columns = null;
                if (string.IsNullOrEmpty(selectionCards[cardIndex].CardColumn))
                {
                    columns = new DataGridViewColumn[selectionCards[cardIndex].ShowCardColumns.Length];
                    for (int j = 0; j < selectionCards[cardIndex].ShowCardColumns.Length; j++)
                    {
                        columns[j] = selectionCards[cardIndex].ShowCardColumns[j];
                    }
                }
                else
                {
                    string[] Columns = selectionCards[cardIndex].CardColumn.Split(new char[] { ',' });
                    columns = new DataGridViewColumn[Columns.Length];
                    for (int k = 0; k < columns.Length; k++)
                    {
                        string[] pms = Columns[k].Split(new char[] { '|' });
                        columns[k] = new DataGridViewTextBoxColumn();
                        columns[k].Name = "col" + pms[0];
                        columns[k].HeaderText = pms[1];
                        columns[k].DataPropertyName = pms[0];
                        if (pms[2] == "auto")
                            columns[k].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                        else
                            columns[k].Width = Convert.ToInt32(pms[2]);
                        columns[k].ReadOnly = true;
                        columns[k].SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
                        //columns[i].DefaultCellStyle = new DataGridViewCellStyle();
                    }
                }
                cardDataGrid.textdataGrid.Columns.Clear();
                cardDataGrid.textdataGrid.Columns.AddRange(columns);
                cardDataGrid.Tag = selectionCards[cardIndex];
                DataGridViewSelectionCard selectionCardInfo = selectionCards[cardIndex];
                cardDataGrid.Width = selectionCardInfo.CardSize.Width;
                cardDataGrid.Height = selectionCardInfo.CardSize.Height;
                cardDataGrid.textpager.IsPage = selectionCardInfo.IsPage;
                cardDataGrid.textpager.DataSource = selectionCardInfo.DataSource;
            }
            cardDataGrid.letterpanel.Visible = IsShowLetter;
            cardDataGrid.textpager.Visible = IsShowPage;
            cardDataGrid.DrawLetter();
            
            cardDataGrid.Hide();

            if (PageNoChanged != null)
            {
                cardDataGrid.textpager.PageNoChanged += new PagerEventHandler(textpager_PageNoChanged);
                cardDataGrid.textpager.pageNo = 1;
            }
        }