private void ChangeCellToComboBox(int iRowIndex) { if (bIsComboBox == false) { WMIMethods methods = new WMIMethods(); List <DNS> dt = methods.GetDNSArray(0); DataGridViewComboBoxCell dgComboCell = new DataGridViewComboBoxCell(); dgComboCell.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; if (dt.Count > 0) { var bindsList = new BindingList <DNS>(dt); var source = new BindingSource(bindsList, null); dgComboCell.DataSource = source; } //dgComboCell.DataSource = dt; dgComboCell.ValueMember = "DNSServer"; dgComboCell.DisplayMember = "DNSServer"; ConnectionsdataGridView.Rows[iRowIndex].Cells[ConnectionsdataGridView.CurrentCell.ColumnIndex] = dgComboCell; bIsComboBox = true; } }
private DataGridViewComboBoxColumn GetDNSComboBox(int conn_id) { DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn() { //CellTemplate = cell, Name = "DNSServer", HeaderText = "DNS-серверы", DataPropertyName = "DNSServer", // Tell the column which property it should use DisplayMember = "DNSServer", ValueMember = "DNSServer", //Width = 120, AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells, }; WMIMethods methods = new WMIMethods(); List <DNS> dnslist = methods.GetDNSArray(conn_id); if (dnslist.Count > 0) { var bindsList = new BindingList <DNS>(dnslist); var source = new BindingSource(bindsList, null); cmb.DataSource = source; } return(cmb); }
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; } }