I am trying to make a program that once there is a change on a combobox it takes the text property of that and finds in an xml a matching name then it shows only the entries with those names to a datagrid. See the image for reference: http://ift.tt/1ttJdAm See how it shows more then Doogie? that's because currently I have it set to show the entire AppointmentList But what it should do is only show the doctor selected.
now my current code looks like this:
Private Sub CBX_Doctors_SelectedIndexChanged(sender As Object, e As EventArgs) Handles CBX_Doctors.SelectedIndexChanged
Dim doctorName As String = CBX_Doctors.SelectedItem.ToString
DGV_1.DataSource = AppointmentList.Where(Function(apt) apt.DoctorName = doctorName)
End Sub
However this only shows a blank datagrid, on debug I get this: http://ift.tt/1405zVt
So it does find a match, but for some reason the datagrid is not given anything to show...
The appointmentlist is declared in a controller module as such:
Module Controller
Public PatientList As New List(Of Patient)
Public DoctorList As New List(Of Doctor)
Public AppointmentList As New List(Of Appointment)
End Module
and Appointment looks like this:
Public Class Appointment
Property AppointmentID As String
Property AppointmentDate As String
Property Time As String
Property AppointmentLength As Integer
Property DoctorName As String
Property PatientName As String
Property Reason As String
End Class
the XML is too large to just post here, so I am adding just a snippet of it:
<ArrayOfAppointment xmlns:xsi="http://ift.tt/ra1lAU" xmlns:xsd="http://ift.tt/tphNwY">
<Appointment>
<AppointmentID>700864b004e84b139119227d88388dcb</AppointmentID>
<AppointmentDate>10/30/2014</AppointmentDate>
<Time>7:20 AM</Time>
<AppointmentLength>15</AppointmentLength>
<DoctorName>Doogie Howser</DoctorName>
<PatientName>Harry Potter</PatientName>
<Reason>The patient has severe scared tissue at forehead, wishes to have it removed. </Reason>
</Appointment>
</ArrayOfAppointment>
I serialize the xml like this:
'save to the xml
Dim objStreamWriter4 As New StreamWriter("..\..\..\Appointments.xml")
Dim a As New XmlSerializer(AppointmentList.GetType)
a.Serialize(objStreamWriter4, AppointmentList)
objStreamWriter4.Close()
No comments:
Post a Comment