Hi all, I must admit I'm rather stumped by this one. I have a program that handles tickets/prizes for a business. Patrons obtain tickets, and then go to turn them in at a counter. An employee counts their tickets, and inputs that number into my program. The program then displays a list of prizes, filtered by ticket value. For example, under the Ticket Level 2 might be a pen and a coaster. Ticket level 5 might contain a t-shirt. Anyway, the users select how many of certain prize they want. The program then subtracts the appropriate number of tickets from the total.
I have this program working as a WinForm, by using variables (i.e. TicketsLeft) and a two column DataGridView, filtered by a ComboBox.
Here is an example of the existing WinForms program:
http://www.daniweb.com/forums/attachment.php?attachmentid=20127&stc=1&d=1300759795
Well, it worked great until the client decided to move to the flashy interface of WPF.
I'm rewriting the code, so it fills a "Customer" class with the information that used to go in the Form Variables, but I've hit a snag. I can't seem to access the underlying customer class to copy data back from the DataGridView.
Here is the working WinForms Code. (Pardon the Visual Basic):
If DataGridView1.Rows.Count <> 0 Then
For I = 0 To DataGridView1.Rows.Count - 1
For J = 0 To UBound(PrizeList)
If PrizeList(J, 0) = DataGridView1.Rows.Item(I).Cells(0).Value AndAlso PrizeList(J, 2) = ComboBox2.SelectedItem Then
If Not IsNumeric(DataGridView1.Rows.Item(I).Cells(1).Value) Then Me.GroupBox1.BackColor = Color.Red : GetLocalError(True) : Exit Sub
PrizeList(J, 1) = DataGridView1.Rows.Item(I).Cells(1).Value
Exit For
End If
Next
Next
End If
TL = TW
For I = 0 To UBound(PrizeList)
If PrizeList(I, 1) = "0" Then Continue For
If Not IsNumeric(PrizeList(I, 1)) Then Me.GroupBox1.BackColor = Color.Red : GetLocalError(True) : Exit Sub
TL = TL - (CInt(PrizeList(I, 1)) * PrizeList(I, 2))
Next
And, here is my rewritten C# WPF code:
XAML:
xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
<!-- Other code here --> <wfi:WindowsFormsHost Margin="0,65.54,0,0">
<wf:DataGridView x:Name="myDG">
</wf:DataGridView>
</wfi:WindowsFormsHost>
And heres the C# code:
void myDG_CellEndEdit(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
{
}
Thats it. Stuck. Ideally I would have this:
WPF.Customer.Prizelist[ //Implementation of the same VB logic from above