GrapeCity.Win.MultiRow Namespace > GcMultiRow Class : DataSource Property |
<FeatureAttribute(Name="DataBinding", Version="v5.0")> <SRCategoryAttribute("Data")> <SRDescriptionAttribute("Indicates the source of data for the GcMultiRow control.")> <AttributeProviderAttribute(TypeName="System.ComponentModel.IListSource, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", PropertyName="")> <DefaultValueAttribute()> Public Property DataSource As Object
Dim instance As GcMultiRow Dim value As Object instance.DataSource = value value = instance.DataSource
[Feature(Name="DataBinding", Version="v5.0")] [SRCategory("Data")] [SRDescription("Indicates the source of data for the GcMultiRow control.")] [AttributeProvider(TypeName="System.ComponentModel.IListSource, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", PropertyName="")] [DefaultValue()] public object DataSource {get; set;}
Exception | Description |
---|---|
System.Exception | An error occurred in the data source and either there is no handler for the DataError event or the handler has set the ThrowException property to true. |
The GcMultiRow class supports the standard Windows Forms data binding model. This means the data source can be of any type that implements one of the following interfaces:
Typically, you bind to a System.Windows.Forms.BindingSource component and bind the System.Windows.Forms.BindingSource component to another data source or populate it with business objects. The System.Windows.Forms.BindingSource component is the preferred data source because it can bind to a wide variety of data sources and can resolve many data binding issues automatically.
Note: |
---|
When you assign a data source to GcMultiRow, you should assign the GcMultiRow control a template where the cells in the template are set to a valid DataField. The DataField value should be a column name of the data source; otherwise, GcMultiRow cells cannot display the data source value. You can use a template designer to select a data field for the cell. |
When binding to a data source that contains multiple lists or tables, you must set the DataMember property to a string that specifies the list or table to bind to. When binding to a System.Windows.Forms.BindingSource component that contains multiple lists or tables; however, you can set the DataMember property of the System.Windows.Forms.BindingSource component instead.
public class DataBindingDemo : Form { private GcMultiRow gcMultiRow1 = new GcMultiRow(); public DataBindingDemo() { this.Text = "DataBinding Demo"; // Add MultiRow to form this.gcMultiRow1.Dock = DockStyle.Fill; this.Controls.Add(this.gcMultiRow1); this.Load += new EventHandler(Form1_Load); } private void Form1_Load(object sender, EventArgs e) { InitializeDataSource(); // The following code can used instead: // this.gcMultiRow1.DataSource = studentInfoDataSet.Tables["BasicInfos"]; this.gcMultiRow1.DataSource = studentInfoDataSet; this.gcMultiRow1.DataMember = "BasicInfos"; // When data binding, the cells in the template should set the DataField property to bind a specific column in the data source. this.gcMultiRow1.Template = this.CreateDataBindingTamplate(); this.gcMultiRow1.DataError += new EventHandler<DataErrorEventArgs>(gcMultiRow1_DataError); }
Public Class DataBindingDemo Inherits Form Friend WithEvents gcMultiRow1 As New GcMultiRow() Public Sub New() Me.Text = "DataBinding Demo" ' Add MultiRow to form Me.gcMultiRow1.Dock = DockStyle.Fill Me.Controls.Add(Me.gcMultiRow1) End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load InitializeDataSource() ' The following code can be used instead: ' this.gcMultiRow1.DataSource = studentInfoDataSet.Tables["BasicInfos"]; Me.gcMultiRow1.DataSource = studentInfoDataSet Me.gcMultiRow1.DataMember = "BasicInfos" ' When data binding, the cells in the template should set the DataField property to bind a specific column in the data source. Me.gcMultiRow1.Template = Me.CreateDataBindingTamplate() End Sub
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2