private void FillGrid() { //this gets called a lot if typing search. So just include the following line in other places. //_listConnsAll=CentralConnections.GetConnections(); _listConnsShowing = null; if (comboConnectionGroups.SelectedIndex > 0) { _listConnsShowing = CentralConnections.FilterConnections(_listConnsAll, textSearch.Text, _listConnectionGroups[comboConnectionGroups.SelectedIndex - 1]); } else { _listConnsShowing = CentralConnections.FilterConnections(_listConnsAll, textSearch.Text, null); } gridMain.BeginUpdate(); gridMain.ListGridColumns.Clear(); GridColumn col; col = new GridColumn("#", 40); gridMain.ListGridColumns.Add(col); col = new GridColumn("Database", 300); gridMain.ListGridColumns.Add(col); col = new GridColumn("Note", 260); gridMain.ListGridColumns.Add(col); gridMain.ListGridRows.Clear(); GridRow row; int[] selectedIndices = gridMain.SelectedIndices; for (int i = 0; i < _listConnsShowing.Count; i++) { row = new GridRow(); row.Cells.Add(_listConnsShowing[i].ItemOrder.ToString()); if (_listConnsShowing[i].DatabaseName == "") //uri { row.Cells.Add(_listConnsShowing[i].ServiceURI); } else { row.Cells.Add(_listConnsShowing[i].ServerName + ", " + _listConnsShowing[i].DatabaseName); } row.Cells.Add(_listConnsShowing[i].Note); gridMain.ListGridRows.Add(row); } gridMain.EndUpdate(); gridMain.SetSelected(selectedIndices, true); }
///<summary>connNums is a list of CentralConnectionNums which is used primarily for filtering out connections through the Refresh button press.</summary> private void FillGrid(List <long> connNums) { List <CentralConnection> listConnsFiltered = null; if (comboConnectionGroups.SelectedIndex > 0) { listConnsFiltered = CentralConnections.FilterConnections(_listConns, textConnSearch.Text, _listConnectionGroups[comboConnectionGroups.SelectedIndex - 1]); } else { listConnsFiltered = CentralConnections.FilterConnections(_listConns, textConnSearch.Text, null); } if (listConnsFiltered.Exists(x => x.ServiceURI != "")) { labelSyncMiddleTier.Visible = true; butSyncManual.Visible = true; } else { labelSyncMiddleTier.Visible = false; butSyncManual.Visible = false; } gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col; col = new ODGridColumn("#", 40); gridMain.Columns.Add(col); col = new ODGridColumn("Database", 320); gridMain.Columns.Add(col); col = new ODGridColumn("Note", 300); gridMain.Columns.Add(col); col = new ODGridColumn("Status", 100, HorizontalAlignment.Center); gridMain.Columns.Add(col); gridMain.Rows.Clear(); ODGridRow row; foreach (CentralConnection conn in listConnsFiltered) { if (connNums != null && !connNums.Contains(conn.CentralConnectionNum)) { continue; //We only want certain connections showing up in the grid. } string status = conn.ConnectionStatus; row = new ODGridRow(); row.Cells.Add(conn.ItemOrder.ToString()); if (conn.DatabaseName == "") //uri { row.Cells.Add(conn.ServiceURI); } else { row.Cells.Add(conn.ServerName + ", " + conn.DatabaseName); } row.Cells.Add(conn.Note); if (status == "") { row.Cells.Add("Not checked"); row.Cells[3].ColorText = Color.DarkGoldenrod; } else if (status == "OK") { row.Cells.Add(status); row.Cells[3].ColorText = Color.Green; row.Cells[3].Bold = YN.Yes; } else if (status == "OFFLINE") { row.Cells.Add(status); row.Bold = true; row.ColorText = Color.Red; } else { row.Cells.Add(status); row.Cells[3].ColorText = Color.Red; } row.Tag = conn; gridMain.Rows.Add(row); } gridMain.EndUpdate(); }