Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Add new appointment (Read 7907 times)
TataTomy
YaBB Newbies
*
Offline


Don't worry - be :)

Posts: 8
Joined: Nov 23rd, 2010
Add new appointment
Nov 23rd, 2010 at 3:34pm
Print Post  
Hi,

i found a way how to create new appointment from program:


Private Sub FormPlan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim i As Integer = 0

For i = 0 To 25
Dim aLocation As MindFusion.Scheduling.Location = New MindFusion.Scheduling.Location
aLocation.Id = "myLoc" & i
aLocation.Name = "Location " & Str(i)
Me.Calendar1.Locations.Add(aLocation)
Next

Calendar1.InteractiveItemType = GetType(MyApp)

End Sub



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim varLoc As Integer

varLoc = Val(TextBox3.Text)

Dim app As New Appointment()
app.HeaderText = "TataTomy"
app.DescriptionText = "Comment"
app.StartTime = New DateTime(2010, 11, 22, 14, 0, 0)
app.EndTime = New DateTime(2010, 11, 24, 10, 0, 0)
app.Location = Calendar1.Locations(varLoc)

Calendar1.Schedule.Items.Add(app)

End Sub

but I still did not found a way how to create new appointment with same elements by drawing at calendar with mouse...

my calendar has currentview = resourceview

can you help me?
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Add new appointment
Reply #1 - Nov 23rd, 2010 at 4:12pm
Print Post  
Appointments are created (drawn) interactively by first selecting a time interval with the mouse and then typing. The newly created appointment spans the selected time interval. Its HeaderText is set to the text entered by the user in the text box. Its DescriptionText however needs to be set through other means. For example, you can handle the ItemCreated event and display a custom form or implement a custom item editor.

Appointments can also be created interactively through dragging. To enable this functionality, set Calendar.EnableDragCreate to true.

Let me know if this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
TataTomy
YaBB Newbies
*
Offline


Don't worry - be :)

Posts: 8
Joined: Nov 23rd, 2010
Re: Add new appointment
Reply #2 - Nov 23rd, 2010 at 4:44pm
Print Post  
God bless you Meppy! The secret was in "set Calendar.EnableDragCreate to true"
  
Back to top
 
IP Logged
 
TataTomy
YaBB Newbies
*
Offline


Don't worry - be :)

Posts: 8
Joined: Nov 23rd, 2010
Re: Add new appointment
Reply #3 - Nov 23rd, 2010 at 5:07pm
Print Post  
One more question: how to move appointment over calendar verticaly (changing locations) with mouse (drag & drop)?
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Add new appointment
Reply #4 - Nov 24th, 2010 at 6:58am
Print Post  
You need to hold down the modifier key specified by ItemChangeReferenceKey (by default it's ALT) before starting to moving the item.

Let me know if it helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
TataTomy
YaBB Newbies
*
Offline


Don't worry - be :)

Posts: 8
Joined: Nov 23rd, 2010
Re: Add new appointment
Reply #5 - Nov 24th, 2010 at 8:20am
Print Post  
It works, of course... Thank you very much...
Actualy - there is a lot possibilities in all events, methods, classes...
  
Back to top
 
IP Logged
 
TataTomy
YaBB Newbies
*
Offline


Don't worry - be :)

Posts: 8
Joined: Nov 23rd, 2010
Re: Add new appointment
Reply #6 - Nov 24th, 2010 at 9:11am
Print Post  
Next question: how can I select and control an appointment form program... I need to change item.style.fillcolor by click one of several buttons (ex. ButtonRed, ButtonGreen, ButtonYellow)...

As a first step I get item.id with

Private Sub Calendar1_ItemClick(ByVal sender As Object, ByVal e As MindFusion.Scheduling.WinForms.ItemMouseEventArgs) Handles Calendar1.ItemClick
       If e.Button = Windows.Forms.MouseButtons.Left Then
           TextBox3.Text = e.Item.Id
       End If
    End Sub


but I do not know how to select an item (Item.Id is i TextBox3.Text) and change color

Have you got something like:

Calendar1.Item.Id(Textbox3.Text).FillColor = Color.Red

I belive you have somethnig good...

Tomy
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Add new appointment
Reply #7 - Nov 24th, 2010 at 12:18pm
Print Post  
An item can be identified by its Id by passing the id as an index to the Schedule.Items collection:

Code
Select All
calendar.Schedule.Items(itemId) 


Items can be selected programmatically by adding them to the Calendar.ItemSelection object:

Code
Select All
calendar.ItemSelection.Add(item) 


The background color of the items in Resource view is specified through the HeaderBrush property of the corresponding item style. For example:

Code
Select All
item.Style.HeaderBrush = New MindFusion.Drawing.SolidBrush(Color.Red)
item.SelectedStyle.HeaderBrush = New MindFusion.Drawing.SolidBrush(Color.Red) 


Let me know if this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
TataTomy
YaBB Newbies
*
Offline


Don't worry - be :)

Posts: 8
Joined: Nov 23rd, 2010
Re: Add new appointment
Reply #8 - Nov 25th, 2010 at 4:39am
Print Post  
This is exactly what I need... Thank you very, very much...
Tomy
  
Back to top
 
IP Logged
 
TataTomy
YaBB Newbies
*
Offline


Don't worry - be :)

Posts: 8
Joined: Nov 23rd, 2010
Re: Add new appointment
Reply #9 - Nov 29th, 2010 at 4:18pm
Print Post  
I have problem with:

System.NullReferenceException was unhandled
  Message="Object reference not set to an instance of an object."
  Source="MindFusion.Scheduling"
  StackTrace:
      at MindFusion.Scheduling.Item.GetHashCode()
      at MindFusion.Scheduling.WinForms.x30788aa4e2c76c13.GetHashCode(Item a)
      at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
      at System.Collections.Generic.Dictionary`2.ContainsKey(TKey key)
      at MindFusion.Scheduling.WinForms.Calendar.xb33e7b23311adcf5(Item xccb63ca5f63dc470)
      at MindFusion.Scheduling.WinForms.Calendar.x4342ef569299dc36(ICollection xf8b54ce7724a27f2)
      at MindFusion.Scheduling.WinForms.Calendar.OnMouseMove(MouseEventArgs e).....


This problem occurs when I try to create new item - appointment with mouse on calendar AFTER I loaded old appointments from database...

there is sample code I used...

by _Load:

Dim app As New Appointment()
                       app.Id = DataGridView_Rezervacije.Rows(iBroj).Cells(0).Value
                       app.HeaderText = DataGridView_Rezervacije.Rows(iBroj).Cells(0).Value & " / Kupac"
                       app.DescriptionText = "Comment"
                       app.Location = Calendar_Glavni.Locations(jBroj)
                       app.StartTime = New DateTime(Int(Format(varDolazak, "yyyy")), _
                                                    Int(Format(varDolazak, "MM")), _
                                                    Int(Format(varDolazak, "dd")), 14, 0, 0)
                       app.EndTime = New DateTime(Int(Format(varOdlazak, "yyyy")), _
                                                    Int(Format(varOdlazak, "MM")), _
                                                    Int(Format(varOdlazak, "dd")), 10, 0, 0)                        
                       Calendar_Glavni.Schedule.Items.Add(app)
                       Calendar_Glavni.ItemSelection.Clear()
                       Calendar_Glavni.ItemSelection.Add(app)



by _ItemCreated:

e.Item.Style.FillColor = Color.Yellow
       e.Item.HeaderText = "New"
       e.Item.DescriptionText = "Tata Tomy / " & FormatDateTime(Now, DateFormat.GeneralDate)
       e.Item.StartTime = New DateTime(Int(Format(e.Item.StartTime, "yyyy")), _
                                       Int(Format(e.Item.StartTime, "MM")), _
                                       Int(Format(e.Item.StartTime, "dd")), _
                                       14, 0, 0)
       e.Item.EndTime = New DateTime(Int(Format(e.Item.EndTime, "yyyy")), _
                                       Int(Format(e.Item.EndTime, "MM")), _
                                       Int(Format(e.Item.EndTime, "dd")), _
                                       10, 0, 0)


Can you help me?

Tomy
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Add new appointment
Reply #10 - Nov 30th, 2010 at 10:14am
Print Post  
Can you check if the Item.Id is Nothing after the following call:

Code
Select All
app.Id = DataGridView_Rezervacije.Rows(iBroj).Cells(0).Value 


Item.Id cannot be Nothing. If it is, assign a value to it but make sure that it is unique within this schedule.

Let me know if this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
TataTomy
YaBB Newbies
*
Offline


Don't worry - be :)

Posts: 8
Joined: Nov 23rd, 2010
Re: Add new appointment
Reply #11 - Nov 30th, 2010 at 11:25am
Print Post  
God bless you, Meppy! It works...
Thanks again...
Tomy
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Add new appointment
Reply #12 - Nov 30th, 2010 at 12:24pm
Print Post  
God bless you too, Tomy!

Regards,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint