Here is the positioning code. Note that we have a preference of using the bottom row for these purposes.
Private Sub PositionTextbox()
calMain.Invalidate()
Dim Elements As List(Of RadElement) = calMain.CalendarElement.GetDescendants(Function(x) TypeOf x Is CalendarCellElement, TreeTraversalMode.BreadthFirst)
Dim FirstDayCellRectangle As Rectangle = Rectangle.Empty
Dim LastDayCellRectangle As Rectangle = Rectangle.Empty
Dim DefaultCellWidth As Integer = -1
Dim ElementTableRectangle As Rectangle = Rectangle.Empty
For i As Integer = 0 To Elements.Count - 1
Dim Cell As CalendarCellElement = Elements(i)
If i = 0 Then
ElementTableRectangle = Cell.Parent.ControlBoundingRectangle
DefaultCellWidth = ElementTableRectangle.Width / 7
End If
If Cell.Date = calMain.CalendarElement.View.ViewStartDate Then
FirstDayCellRectangle = Cell.ControlBoundingRectangle
'there are multiple of these, but it appears that the last one is the one we want
ElseIf Cell.Date = calMain.CalendarElement.View.ViewEndDate Then
LastDayCellRectangle = Cell.ControlBoundingRectangle
rtbNotes.Height = Cell.ControlBoundingRectangle.Height
Exit For
End If
Next
If FirstDayCellRectangle <> Rectangle.Empty AndAlso LastDayCellRectangle <> Rectangle.Empty AndAlso ElementTableRectangle <> Rectangle.Empty Then
'a difference of 1 would probably work here, but we use a larger amount in case padding/margins/themes move things
If LastDayCellRectangle.Bottom < (ElementTableRectangle.Bottom - 20) Then
'take entire last row
rtbNotes.Top = ElementTableRectangle.Top + ElementTableRectangle.Height - rtbNotes.Height
rtbNotes.Width = ElementTableRectangle.Width
rtbNotes.Left = ElementTableRectangle.Left
ElseIf LastDayCellRectangle.Left = ElementTableRectangle.Left Then
'take entire first row
rtbNotes.Top = FirstDayCellRectangle.Top - FirstDayCellRectangle.Height
rtbNotes.Width = ElementTableRectangle.Width
rtbNotes.Left = ElementTableRectangle.Left
ElseIf (ElementTableRectangle.Width - LastDayCellRectangle.Right) >= FirstDayCellRectangle.Left Then
'take remainder of last row
rtbNotes.Top = ElementTableRectangle.Top + ElementTableRectangle.Height - rtbNotes.Height
rtbNotes.Width = ElementTableRectangle.Width - LastDayCellRectangle.Right
rtbNotes.Left = ElementTableRectangle.Width - rtbNotes.Width
Else
'take remainder of first row
rtbNotes.Top = FirstDayCellRectangle.Top
rtbNotes.Width = FirstDayCellRectangle.Left
rtbNotes.Left = ElementTableRectangle.Left
End If
End If
rtbNotes.BringToFront()
End Sub