'宣言 Public ReadOnly Property PropertyDescriptor As PropertyDescriptor
public PropertyDescriptor PropertyDescriptor {get;}
Imports Infragistics.Shared Imports Infragistics.Win Imports Infragistics.Win.UltraWinGrid Imports System.Diagnostics Private Sub Button14_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button14.Click Dim band As UltraGridBand = Me.UltraGrid1.DisplayLayout.Bands(0) ' Check if the column has already been added. If Not band.Columns.Exists("UBColumn1") Then ' Add an unbound column with the key of "UBColumn1" band.Columns.Add("UBColumn1") band.Columns("UBColumn1").DataType = GetType(String) End If ' Loop through all the columns and print out the keys of the columns that are ' unbound. There will be only one such column since we've added only one unbound ' column above. Dim i As Integer For i = 0 To band.Columns.Count - 1 ' IsBound indicates whether a column is a bound column or is an unbound column. If Not band.Columns(i).IsBound Then Debug.WriteLine(band.Columns(i).Key & " is an unbound column") Else ' Each bound column has a PropertyDescriptor associated with it. PropertyDescriptor is ' associated with a column or field in the underlying data structure. The UltraGrid ' gets property descriptors through BindingManagerBase.GetItemProperties method. Dim pd As System.ComponentModel.PropertyDescriptor = band.Columns(i).PropertyDescriptor Debug.WriteLine(band.Columns(i).Key & " is a bound column. Property descriptor info: Name = " & pd.Name & ", Type = " & pd.PropertyType.Name) End If Next End Sub
using Infragistics.Shared; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; using System.Diagnostics; private void button14_Click(object sender, System.EventArgs e) { UltraGridBand band = this.ultraGrid1.DisplayLayout.Bands[0]; // Check if the column has already been added. if ( !band.Columns.Exists( "UBColumn1" ) ) { // Add an unbound column with the key of "UBColumn1" band.Columns.Add( "UBColumn1" ); band.Columns["UBColumn1"].DataType = typeof( string ); } // Loop through all the columns and print out the keys of the columns that are // unbound. There will be only one such column since we've added only one unbound // column above. for ( int i = 0; i < band.Columns.Count; i++ ) { // IsBound indicates whether a column is a bound column or is an unbound column. if ( !band.Columns[i].IsBound ) { Debug.WriteLine( band.Columns[i].Key + " is an unbound column" ); } else { // Each bound column has a PropertyDescriptor associated with it. PropertyDescriptor is // associated with a column or field in the underlying data structure. The UltraGrid // gets property descriptors through BindingManagerBase.GetItemProperties method. System.ComponentModel.PropertyDescriptor pd = band.Columns[i].PropertyDescriptor; Debug.WriteLine( band.Columns[i].Key + " is a bound column. Property descriptor info: Name = " + pd.Name + ", Type = " + pd.PropertyType.Name ); } } }