Friday, 6 September 2013

WPF DataGridComboBoxColumn Binding using Visual Basic?

WPF DataGridComboBoxColumn Binding using Visual Basic?

Using Visual Basic, I have a WPF APPLICATION**
The first person that can give me working code (on my system) using Visual
Basic WPF Application as it works in Visual Studio 2010, and the data I've
provided, I will transfer $100.00 US to you via PayPal.
Details
In that WPF App, I have a DataGrid named "dgvInjuries"
In dgvInjuries, I would like to have three DataGridTextColumns
(EmployeeID, FirstName, LastName) and one DataGridComboBoxColumn named
"InjuryID"
The data is coming from a MS SQL Database. I would like to be able to
populate the dgvInjuries DataGrid with data from a table called
"tbl_Incidents."
The dgvInjuries DataGrid should be able to Display, Add and Update
rows/records in the tbl_Incidents table.
I would like to be able to populate the InjuryID DatagridComboBoxColumn
with data from a table called "tbl_Injuries"
The InjuryID DatagridComboBoxColumn should use the Descript field from
tbl_Injuries as the DisplayMemberPath.
The InjuryID DatagridComboBoxColumn should use the ID field from
tbl_Injuries as the SelectedValuePath.
I am using the following code to populate the dgvInjuries DataGrid:
Xaml –
<DataGrid AutoGenerateColumns="False"
Height="146"
HorizontalAlignment="Left"
Margin="6,6,0,0"
Name="dgvInjuries"
VerticalAlignment="Top"
Width="374"
ItemsSource="{Binding}">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding EmployeeID}"
Header="EmployeeID"/>
<DataGridTextColumn Binding="{Binding FirstName}"
Header="FirstName"/>
<DataGridTextColumn Binding="{Binding LastName}"
Header="LastName"/>
<DataGridComboBoxColumn x:Name="InjuryID"
ItemsSource="{Binding}"
Header="InjuryID
Width="150"
DisplayMemberPath="Descript"
SelectedValuePath="ID" />
</DataGrid.Columns>
</DataGrid>
Code Behind -
Dim Injuries_DA As SqlDataAdapter
Dim Injuries_DataTable As New DataTable
Dim Injuries_DS As New DataSet
Injuries_DA = New SqlDataAdapter("Select EmployeeID, FirstName, LastName,
InjuryID FROM ChazTest ORDER BY EmployeeID", RMS_conn)
Injuries_DA.Fill(Injuries_DataTable)
dgvInjuries.ItemsSource = Injuries_DataTable.DefaultView
For the InjuryID DatagridComboBoxColumn, I would like to access the MS SQL
database in much the same way as I have done for the dgvInjuries DataGrid
(using Code Behind).
Can anyone help me with the XAML and CodeBehind that I am missing/using
incorrectly? I have been going in circles for a month.
As you can see I am using Visual Basic (in Visual Studio 2010).
Additionally, the first person that can give me working code (on my
system) using Visual Basic WPF as it works in Visual Studio 2010, and the
data I've provided, I will transfer $100.00 US to you via PayPal.
I'm exhausted from trying to figure this out…

No comments:

Post a Comment