private static object GetLookupListValue(ILookupList lookupList) { return(((lookupList == null) || (lookupList is NullLookupList)) ? null : RandomValueGen.GetRandomLookupListValue(lookupList.GetLookupList())); }
private void CreateColumnForUIDef(IClassDef classDef, IUIGrid gridDef) { foreach (IUIGridColumn gridColDef in gridDef) { IDataGridViewColumn col; if (gridColDef.GridControlTypeName == "DataGridViewComboBoxColumn") { IDataGridViewComboBoxColumn comboBoxCol = _controlFactory.CreateDataGridViewComboBoxColumn(); IPropDef propDef = GetPropDef(classDef, gridColDef); ILookupList source = null; if (propDef != null) { source = propDef.LookupList; } if (source != null) { DataTable table = new DataTable(); table.Columns.Add("id"); table.Columns.Add("str"); table.LoadDataRow(new object[] { "", "" }, true); foreach (KeyValuePair <string, string> pair in source.GetLookupList()) { table.LoadDataRow(new object[] { pair.Value, pair.Key }, true); } comboBoxCol.DataSource = table; // ReSharper disable ConditionIsAlwaysTrueOrFalse //Hack_: This null check has been placed because of a Gizmox bug_ // We posted this at: http://www.visualwebgui.com/Forums/tabid/364/forumid/29/threadid/12420/scope/posts/Default.aspx // It is causing a StackOverflowException on ValueMember because the DataSource is still null if (comboBoxCol.DataSource != null) { comboBoxCol.ValueMember = "str"; comboBoxCol.DisplayMember = "str"; } // ReSharper restore ConditionIsAlwaysTrueOrFalse } comboBoxCol.DataPropertyName = gridColDef.PropertyName; col = comboBoxCol; this.GridBase.Columns.Add(col); } else if (gridColDef.GridControlTypeName == "DataGridViewCheckBoxColumn") { col = _controlFactory.CreateDataGridViewCheckBoxColumn(); this.GridBase.Columns.Add(col); } else { col = CreateCustomColumn(gridColDef); } col.HeaderText = gridColDef.GetHeading(); col.Name = gridColDef.PropertyName; col.DataPropertyName = gridColDef.PropertyName; col.Width = gridColDef.Width; col.Visible = gridColDef.Width != 0; col.SortMode = DataGridViewColumnSortMode.Automatic; col.ReadOnly = !gridColDef.Editable; Type propertyType = GetPropertyType(classDef, gridColDef.PropertyName); if (propertyType != typeof(object)) { col.ValueType = propertyType; } SetupColumnWithDefParameters(col, gridColDef, propertyType); } }
private static object GetLookupListValue(ILookupList lookupList) { return (((lookupList == null) || (lookupList is NullLookupList)) ? null : RandomValueGen.GetRandomLookupListValue(lookupList.GetLookupList())); }