Beispiel #1
0
        //配列に要素を追加。同じ名前の要素が来たら末尾に追加する。
        public void Add(CoveringIterator tpItem)
        {
            bool blFind = false;
            int  nIndex = 0;

            // 同じ名前の要素があるか探す
            for (int i = 0; i < CtpTable.Length; i++)
            {
                if (CtpTable[i].Name == tpItem.Name)
                {
                    blFind = true;
                    nIndex = i;
                    break;
                }
            }

            if (blFind) //あったらマージ
            {
                string[] stItemArr  = tpItem.GetItemArr();
                bool[]   blValidArr = tpItem.GetValidArr();

                CtpTable[nIndex].Add(stItemArr, blValidArr);
            }
            else //なければ普通に追加
            {
                int nMax = CtpTable.Length;
                Array.Resize(ref CtpTable, nMax + 1);
                CtpTable[nMax] = tpItem;
            }
        }
        /// //////////////////////////////////////////////////////////////////////////////////////
        /// 反復子
        /// //////////////////////////////////////////////////////////////////////////////////////

        //反復子をグリッドから取得
        public void GetDataFromGrid(DataGridView GridView)
        {
            string           stName;
            string           stItem;
            CoveringIterator tpIterator;
            DataGridViewCell cell;

            CtpDataTable = new DataTable();

            for (int nCol = 0; nCol < GridView.ColumnCount; nCol++)
            {
                stName     = GridView.Columns[nCol].HeaderText;
                tpIterator = new CoveringIterator(stName);
                for (int nRow = 0; nRow < GridView.RowCount; nRow++)
                {
                    cell = GridView[nCol, nRow];
                    //空白セルにnullが入っていることがある
                    stItem = (cell.Value != null) ? cell.Value.ToString() : "";
                    tpIterator.Add(stItem, (cell.Style.BackColor != cDisenable));
                }
                CtpDataTable.Add(tpIterator);
            }
        }