コード例 #1
0
        private void BindConnectionGrid(ref DataGridView dgv)
        {
            WMIMethods        methods  = new WMIMethods();
            List <Connection> connlist = methods.GetNetworkDevices();

            AddColumn(ref dgv);
            //dgv.Columns.Add( GetDNSComboBox(connlist[0].Id) );
            //dgv.Columns.Add( GetGatewayComboBox(connlist[0].Id) );

            //SetDNSComboBox(ref ConnectionsdataGridView);

            if (connlist.Count > 0)
            {
                var bindsList = new BindingList <Connection>(connlist);
                //Bind BindingList directly to the DataGrid
                var source = new BindingSource(bindsList, null);
                dgv.DataSource = source;
            }
        }
コード例 #2
0
        private void SetTextBox(ref DataGridView dgv)
        {
            WMIMethods        methods  = new WMIMethods();
            List <Connection> connlist = methods.GetNetworkDevices();

            //Добавление данных
            DataGridViewRow         row      = new DataGridViewRow();
            DataGridViewTextBoxCell cell_txt = new DataGridViewTextBoxCell();

            //Вписываем текст в заголовок строки
            row.HeaderCell.Value = "1";
            row.CreateCells(dgv);
            //Создаем массив который будет помещен в ячейку
            cell_txt.Value   =
                row.Cells[1] = cell_txt;

            //выбираем строчку по умолчанию - здесь выбрана под номером 2.
            row.Cells[1].Value = (row.Cells[1] as DataGridViewComboBoxCell).Items[2];
            //Вносим в dataGridView
            dgv.Rows.Add(row);
        }
コード例 #3
0
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            base.OnFormClosing(e);

            DbMethods         DB              = new DbMethods();
            WMIMethods        methods         = new WMIMethods();
            List <Connection> Connection_list = methods.GetNetworkDevices();
            List <DNS>        DNS_list        = methods.GetDNSArray(Connection_list[0].Id);
            List <Gateway>    Gateway_list    = methods.GetGatewayArray(Connection_list[0].Id);

            if (Connection_list.Count > 0)
            {
                DB.SaveConnectionTable(Connection_list, DNS_list, Gateway_list);
            }

            //DB.ReadConnectionHistory(ref Connection_list);

            if (e.CloseReason == CloseReason.WindowsShutDown)
            {
                return;
            }
        }