/// <summary> /// Display the attributes of a specific row on this property page /// </summary> /// <param name="row">The row of interest (not null)</param> /// <exception cref="ArgumentNullException">If the supplied row is null</exception> internal void SetRow(Row row) { if (row == null) { throw new ArgumentNullException(); } m_Row = row; // Set the text on the tab this.Text = row.Table.TableName; // We'll display any expanded domain values if we can IColumnDomain[] cds = row.Table.ColumnDomains; // Hmm, there isn't a PropertyGrid.DataSource property, so do it the // hard way (is there a better way?) DataRow data = row.Data; DataTable table = data.Table; object[] items = data.ItemArray; AdhocPropertyList props = new AdhocPropertyList(items.Length); for (int i = 0; i < items.Length; i++) { DataColumn dc = table.Columns[i]; string columnName = dc.ColumnName; AdhocProperty item = new AdhocProperty(columnName, items[i]); item.ReadOnly = true; // If the column is associated with a domain, lookup the expanded value and // record as the item's description IColumnDomain cd = Array.Find <IColumnDomain>(cds, t => String.Compare(t.ColumnName, columnName, true) == 0); if (cd != null) { string shortValue = items[i].ToString(); string longValue = cd.Domain.Lookup(m_DataServer.ConnectionString, shortValue); item.Description = longValue; } props.Add(item); } propertyGrid.SelectedObject = props; }
/// <summary> /// Display the attributes of a specific row on this property page /// </summary> /// <param name="row">The row of interest (not null)</param> /// <exception cref="ArgumentNullException">If the supplied row is null</exception> internal void SetRow(Row row) { if (row == null) throw new ArgumentNullException(); m_Row = row; // Set the text on the tab this.Text = row.Table.TableName; // We'll display any expanded domain values if we can IColumnDomain[] cds = row.Table.ColumnDomains; // Hmm, there isn't a PropertyGrid.DataSource property, so do it the // hard way (is there a better way?) DataRow data = row.Data; DataTable table = data.Table; object[] items = data.ItemArray; AdhocPropertyList props = new AdhocPropertyList(items.Length); for (int i=0; i<items.Length; i++) { DataColumn dc = table.Columns[i]; string columnName = dc.ColumnName; AdhocProperty item = new AdhocProperty(columnName, items[i]); item.ReadOnly = true; // If the column is associated with a domain, lookup the expanded value and // record as the item's description IColumnDomain cd = Array.Find<IColumnDomain>(cds, t => String.Compare(t.ColumnName, columnName, true) == 0); if (cd != null) { string shortValue = items[i].ToString(); string longValue = cd.Domain.Lookup(m_DataServer.ConnectionString, shortValue); item.Description = longValue; } props.Add(item); } propertyGrid.SelectedObject = props; }