I have bound my appointments to a dataset and have specified a data member (table name). Everything is displaying properly. I need to get able to retrieve an appointment and I'm trying to use the GetAppointmentFromBindingListObject function. I am passing in a DataRowView that maps to one of the datarows in my bound dataset, but it never returns anything. Any help on what I could be doing wrong?
Hello Richard,
The reason GetAppointmentFromBindingListObject isn't working with DataTable is that you are passing the dataRow object instead of DataRowView object.
If you want to use DataTables, you should cast your DataRow to DataRowView. I made quick test using the code below:
DataTable dt = new DataTable();
dt.Columns.Add("A", typeof(Appointment));
dt.Rows.Add(new Appointment(DateTime.Now, DateTime.Now.AddDays(2)));
dt.Rows.Add(new Appointment(DateTime.Now, DateTime.Now.AddDays(5)));
ultraCalendarInfo1.DataBindingsForAppointments.DataSource = dt;
DataRow dr = dt.Rows[0];
DataRowView drv = dt.DefaultView[dt.Rows.IndexOf(dr)];
Appointment app = ultraCalendarInfo1.Appointments.GetAppointmentFromBindingListObject(drv) as Appointment;
MessageBox.Show(app.Subject);
Another possible approach could be with BindingList<T> rather than a DataSet/DataTable. For example:
BindingList <Appointment> list = new BindingList<Appointment>();
list.Add(new Appointment(DateTime.Now, DateTime.Now.AddDays(2)));
list.Add(new Appointment(DateTime.Now, DateTime.Now.AddDays(5)));
ultraCalendarInfo1.DataBindingsForAppointments.DataSource = list;
Appointment app = ultraCalendarInfo1.Appointments.GetAppointmentFromBindingListObject(list[1]) as Appointment;
Let me know if you have any questions.
Regards
I tried your approach and it still fails on the GetAppointmentFromBindingListObject. Here's my code after using your suggestion:
Dim strImageFilename As String = GetColString(dScheduleJobRow("Drawing_Filename"))
If strImageFilename.Trim <> String.Empty Then
If System.IO.File.Exists(strImageFilename) = True Then
Dim fs As System.IO.FileStream
fs = New System.IO.FileStream(strImageFilename, IO.FileMode.Open, IO.FileAccess.Read)
'get all the appointments for this job and set the image...
Dim dScheduleDetailRows() As DataRow = Me.dsDataEntryItem.Tables("Schedule_Detail").Select("Schedule_Job_ID = " & GetColInteger(dScheduleJobRow("Schedule_Job_ID")).ToString, String.Empty, DataViewRowState.CurrentRows)
If dScheduleDetailRows.Length > 0 Then
For Each dScheduleDetailRow As DataRow In dScheduleDetailRows
Dim drv As DataRowView = Me.dsDataEntryItem.Tables("Schedule_Detail").DefaultView(Me.dsDataEntryItem.Tables("Schedule_Detail").Rows.IndexOf(dScheduleDetailRow))
If Not IsNothing(drv) Then
Dim objAppointment As Appointment = DirectCast(Me.CalendarInfo1.Appointments.GetAppointmentFromBindingListObject(drv), Appointment)
If Not IsNothing(objAppointment) Then
objAppointment.Appearance.Image = System.Drawing.Image.FromStream(fs)
End If
Next
fs.Close()
fs = Nothing
Thanks for attached code, but could you please show me where and how you set your datasource - ultraCalendarInfo1.DataBindingsForAppointments.DataSource
'set DataBindings for Appointments...
Me.CalendarInfo1.DataBindingsForAppointments.SetDataBinding(Me.dsDataEntryItem, "Schedule_Detail")
Me.CalendarInfo1.DataBindingsForAppointments.BindingContextControl = Me
Me.CalendarInfo1.DataBindingsForAppointments.AllPropertiesMember = "All_Properties"
Me.CalendarInfo1.DataBindingsForAppointments.DataKeyMember = "Schedule_Detail_ID"
Me.CalendarInfo1.DataBindingsForAppointments.DescriptionMember = "Step_Description"
Me.CalendarInfo1.DataBindingsForAppointments.EndDateTimeMember = "Scheduled_End_Date"
Me.CalendarInfo1.DataBindingsForAppointments.OriginalStartDateTimeMember = “Original_Scheduled_Start_Date"
Me.CalendarInfo1.DataBindingsForAppointments.OwnerKeyMember = String.Empty
Me.CalendarInfo1.DataBindingsForAppointments.StartDateTimeMember = "Scheduled_Start_Date"
Me.CalendarInfo1.DataBindingsForAppointments.SubjectMember = "Subject"
'set DataBindings for Owners...
Me.CalendarInfo1.DataBindingsForOwners.SetDataBinding(Me.dsDataEntryItem, "Owners")
Me.CalendarInfo1.DataBindingsForOwners.BindingContextControl = Me
Me.CalendarInfo1.DataBindingsForOwners.AllPropertiesMember = "All_Properties"
Me.CalendarInfo1.DataBindingsForOwners.EmailAddressMember = "EMail_Address"
Me.CalendarInfo1.DataBindingsForOwners.KeyMember = "Owners_ID"
Me.CalendarInfo1.DataBindingsForOwners.NameMember = "Owner_Code"
Me.CalendarInfo1.DataBindingsForOwners.VisibleMember = "Visible"
'bind the control to the CalendarInfo and CalendarLook objects...
Me.DayView1.CalendarInfo = Me.CalendarInfo1
Me.DayView1.CalendarLook = Me.CalendarLook1
Me.WeekView1.CalendarInfo = Me.CalendarInfo1
Me.WeekView1.CalendarLook = Me.CalendarLook1
Me.MonthViewSingle1.CalendarInfo = Me.CalendarInfo1
Me.MonthViewSingle1.CalendarLook = Me.CalendarLook1
Me.TimelineView1.CalendarInfo = Me.CalendarInfo1
Me.TimelineView1.CalendarLook = Me.CalendarLook1
I try to reproduce your issue, but without success. Please take a look at the attached video file and if you think that I didn`t reproduce your scenario, please let me know. Also could you please tell me what is your current version and do you have any installed service release and which one. Will be very helpful if you send us small sample that reproduce your issue and I`ll be glad to research it for you.
I am using NetAdvantage 12.1 and I have installed the latest service release. I can't go to 12.2 because my project doesn't currently target version 4.0 of the .Net framework.
I'm not sure what to do at this point. My project is written in VB.Net and has about 100 forms and several hundred thousand lines of code. This is not something that I can easily transform into a one-form, simple project. Is there something wrong with my code? It follows all of your suggestions, but doesn't seem to work.
Hi,
I downgraded my test sample to version 12.1.20121.2135 and CLR 2.0 and everything works properly. Could you please tell me what is your current build (see attached screenshot). If you are using older build, you could donwload the latest available service release for version 12.1 from our site: Infragistics.com -> Account -> My Key and Downloads -> Service Releases If it is not the reason for this strange behavior, I`ll convert my sample to VB to exclude also this difference between our scenarios.
If you need any additional assistance don’t hesitate to ask.
Here is the sample
I made a new sample, where I`m using your version and VB language, but I was not able to reproduce your issue. Could you please take a look at the attached sample and video file (please do not forget to change the connection string to your database) and feel free to modify this sample to reproduce your issue and revert it back to me. I`ll be glad to research it for you.
Let me know if you have any questions
I am using the same build as you are.