Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
80
Checkbox column in hierarchical xamdatagrid
posted

Hi, using the bind sample from the help docs, I am binding SQL data to a XamDataGrid in hierarchical layout.

How can I add a column of checkboxes to the expanded child data?

<code>

void Samp_Loaded(object o, RoutedEventArgs e)

{

// Initialize DataSet and give it a name

this.flatData = new DataSet("flatData");

// Initialize the SqlConnection providing the

// connection string

this.sqlConnection1 =

new SqlConnection("Data Source=localhost;Initial " +

"Catalog=TestDB;Integrated Security=True");

// Initialize the SqlCommand that contains the Select command

this.sqlSelectCommand1 =

new SqlCommand("SELECT CustomerID, CompanyName, " +

"ContactName, ContactTitle, Address, City, PostalCode, " +

"Country, Phone\r\nFROM Customers");

// Assign the SqlConnection to the Connection property of the

// SqlCommand

this.sqlSelectCommand1.Connection = this.sqlConnection1;

// Initialize the SqlDataAdapter

this.sqlDataAdapter1 = new SqlDataAdapter();

// Assign the SelectCommand property to the SqlCommand that has

// been created

this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;

// Initialize the SqlCommand that contains the Select command

 this.sqlSelectCommand2 =

new SqlCommand("SELECT OrderID, CustomerID, OrderDate, " +

"RequiredDate, ShippedDate, ShipVia, Freight, ShipName, ShipAddress, " +

"ShipCity, ShipRegion, ShipPostalCode, " +

"ShipCountry\r\nFROM Orders");

// Assign the SqlConnection to the Connection property of the

// SqlCommand

this.sqlSelectCommand2.Connection = this.sqlConnection1;

// Initialize the SqlDataAdapter

this.sqlDataAdapter2 = new SqlDataAdapter();

// Assign the SelectCommand property to the SqlCommand that has

// been created

this.sqlDataAdapter2.SelectCommand = this.sqlSelectCommand2;

try

{

// Fill the DataSets

this.sqlDataAdapter1.Fill(this.flatData.Tables.Add("Customers"));

this.sqlDataAdapter2.Fill(this.flatData.Tables.Add("Orders"));

// Create a Data Relation between two tables

DataRelation tableRelation =

new DataRelation("hierarchy",

this.flatData.Tables["Customers"].Columns["CustomerID"],this.flatData.Tables["Orders"].Columns["CustomerID"]);

flatData.Relations.Add(tableRelation);

// Assign the DataSet's DefaultView to a control's data source

}

catch (SqlException ex)

{

// Catch and display any exceptions that may occur

MessageBox.Show(ex.Message.ToString());

}

this.XamDataGrid3.DataSource = this.flatData.Tables[0].DefaultView;

</code>

<code>

//XAML code

<igDP:XamDataGrid x:Uid="igDP:XamDataGrid_3" x:Name="XamDataGrid3" Theme="Office2k7Blue" SelectedItemsChanged="XamDataGrid3_SelectedItemsChanged" >

</code>