List allows you to display hierarchical data. Hierarchical data refers to data stored in multiple relational tables, where a master (or "parent") table is linked by key fields to detail (or "child") tables. The hierarchical display provides the ability to present the master data to users, such that the related detail data can be viewed in the same list with a single mouse click.
The following GIF shows how you can display hierarchical data using the List and Combo controls.
Use the following steps to display hierarchical data in the List control. The following example uses the List and Combo controls to display master-detail relationship in the List control.
C# |
Copy Code
|
---|---|
// TODO: This line of code loads data into the 'dataSet1.Composer' table. You can move, or remove it, as needed. this.composerTableAdapter.Fill(this.dataSet1.Composer); |
C# |
Copy Code
|
---|---|
// TODO: This line of code loads data into the 'dataSet2.Opus' table. You can move, or remove it, as needed. this.opusTableAdapter.Fill(this.dataSet2.Opus); |
C# |
Copy Code
|
---|---|
private void C1Combo1_RowChange(object sender, EventArgs e) { DataRow[] dr = this.dataSet2.Opus.Select("Last ='" + this.c1Combo1.Text + "'"); DataSet2.OpusDataTable tb = new DataSet2.OpusDataTable(); foreach (DataRow item in dr) { tb.ImportRow(item); } //modifies the data source of the list control this.c1List1.DataSource = tb; } |