Exemplo n.º 1
0
        /// <summary>
        /// Reads the table from the location "myInfo" assuming that there is a CSV file at this location with "mySeparator" as a separator.
        /// </summary>
        /// <param name="tableToSelect"></param>
        public MyGridEditor(System.IO.FileInfo myInfo, char mySeparator)
        {
            if (myInfo.Exists == false)
            {
                throw new ArgumentException("There is no file at the path " + myInfo.FullName);
            }

            FileNameBox.Text = myInfo.FullName;


            //    MyPath = new FileInfo(myInfo.FullName);
            InitializeComponent();
            throw new NotImplementedException();


            string MyInput = MyFileOperations.ReadFile(myInfo.FullName);

            // MyStringOperations.Dou
            MyTable TableToPut = new MyTable(MyInput, MyStringOperations.EndOfLine, mySeparator.ToString(), true);

            // MyTable tableToPut=new MyTable(myInfo.FullName)
            int           MaxCount = TableToPut.Content.Select(Element => Element.Count()).ToList().Max();///The length of the longest row
            List <string> myHeader = TableToPut.Content[0];

            if (MaxCount > myHeader.Count())
            {
                throw new ArgumentException("Wrong arguments passed to the function DisplayGrid");
            }
            for (int Iterator = 1; Iterator <= myHeader.Count(); Iterator++)
            {
                MyGridView2.Columns.Add(myHeader[Iterator - 1], myHeader[Iterator - 1]);
            }

            int GridRow  = 1;
            int TableRow = 1;

            MyGridView2.RowCount = TableToPut.RowCount();
            while
            (TableRow <= (TableToPut.Count()))
            {
                for (int ColumnIterator = 1; ColumnIterator <= TableToPut[TableRow - 1].Count(); ColumnIterator++)
                {
                    MyGridView2[ColumnIterator - 1, GridRow - 1].Value = TableToPut.Content[TableRow - 1][ColumnIterator - 1];
                }
                GridRow  += 1;
                TableRow += 1;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Fills the control MyGridView2 with the content of the table tableToPut.
        /// The form is displayed modally.
        /// Throws an exception if any row of the table "tableToPut" contains larger number of elements than the
        /// argument "myHeader".
        /// The string "myTitle" is a title which is displayed at the form.
        /// </summary>
        /// <param name="tableToPut">The table which will be placed in the control MyGridView2</param>
        /// <param name="myHeader">The header placed in the first row of the control MyGridView2</param>
        /// <param name="omitHeader">determines if the header's display is omitted</param>
        public DialogResult DisplayGrid(MyTable tableToPut, List <string> myHeader, bool omitHeader = false, string myTitle = "")
        {
            int MaxCount = tableToPut.Content.Select(Element => Element.Count()).ToList().Max();

            if (MaxCount > myHeader.Count())
            {
                throw new ArgumentException("Wrong arguments passed to the function DisplayGrid");
            }
            for (int Iterator = 1; Iterator <= myHeader.Count(); Iterator++)
            {
                MyGridView2.Columns.Add(myHeader[Iterator - 1], myHeader[Iterator - 1]);
            }

            int GridRow  = 1;
            int TableRow = 1;

            if (omitHeader)
            {
                TableRow += 1;
            }
            MyGridView2.RowCount = tableToPut.RowCount();
            this.Text            = myTitle;
            while
            (TableRow <= (tableToPut.Count()))
            {
                for (int ColumnIterator = 1; ColumnIterator <= tableToPut[TableRow - 1].Count(); ColumnIterator++)
                {
                    MyGridView2[ColumnIterator - 1, GridRow - 1].Value = tableToPut.Content[TableRow - 1][ColumnIterator - 1];
                }
                GridRow  += 1;
                TableRow += 1;
            }
            //   CheckState();
            DialogResult MyOutcome = ShowDialog();

            return(MyOutcome);
        }