protected void MontaComboboxfiltros(DAL obj) { PropertyInfo[] props = obj.GetType().GetProperties(); int instancePropsCount = props.Count(); InicializaCombobox(); for (int i = 0; i < instancePropsCount; i++) { if (IsColumn(props[i])) { System.ComponentModel.DisplayNameAttribute displayName = null; try { displayName = ((System.ComponentModel.DisplayNameAttribute)(props[i].GetCustomAttributes(typeof(System.ComponentModel.DisplayNameAttribute), false)[0])); } catch { displayName = null; } if (displayName != null) { ItensComboBox item = new ItensComboBox(); item.displayName = displayName.DisplayName; item.fieldName = props[i].Name; ListaItensComboBox.Add(item); cbbFiltro.Items.Add(item.displayName); } } } cbbFiltro.SelectedIndex = 0; }
private void InicializaCombobox() { ItensComboBox item = new ItensComboBox(); item.displayName = String.Empty; item.fieldName = String.Empty; ListaItensComboBox.Add(item); cbbFiltro.Items.Add(String.Empty); }