Returns the ActiveReports.Section at the specified screen location.
Returns the ActiveReports.Section at the specified point.
Syntax
| Visual Basic (Declaration) | |
|---|
Public Function SectionAt( _
ByVal point As Point _
) As Section |
| Visual Basic (Usage) | Copy Code |
|---|
Dim instance As Designer
Dim point As Point
Dim value As Section
value = instance.SectionAt(point)
|
Parameters
- point
- System.Drawing.Point.
Example
| C# | Copy Code |
|---|
private void arDesigner_DragDrop(object
sender, System.Windows.Forms.DragEventArgs e)
{
//if the data is a ToolboxItem or lvCustomItems is the object being dragged
if ((e.Data.GetDataPresent(typeof(System.Drawing.Design.ToolboxItem))) ||
e.Data.GetData(typeof(System.Windows.Forms.ListView)).Equals(this.lvCustomItems))
{
//get a reference to the ListView control
System.Windows.Forms.ListView lv =
(System.Windows.Forms.ListView)e.Data.GetData(this.lvCustomItems.GetType());
//determine the report section where the drop occurred
DataDynamics.ActiveReports.Section section = this.arDesigner.SectionAt(new Point(e.X, e.Y));
//check if section is null
if (section == null) //drop may have occured outside of any section
{
MessageBox.Show("Please drop items only on visible area of report surface.",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
//get designer form coordinates
Point ptDesigner = this.arDesigner.PointToClient(new Point(e.X, e.Y));
//get section coordinates
Point ptSection = this.arDesigner.PointToSection(section, ptDesigner);
//calculate coordinates where drop occurred
PointF ptControlLocation = new
PointF(ptSection.X / this.arDesignerDpiX, ptSection.Y / this.arDesignerDpiY);
//determine which custom items was dropped
if (lv.SelectedItems[0].Text.CompareTo("Logo") == 0) //logo
{
this.AddLogo(section, ptControlLocation);
}
else if (lv.SelectedItems[0].Text.CompareTo("Disclaimer") == 0) //disclaimer
{
this.AddDisclaimer(section, ptControlLocation);
}
else if (lv.SelectedItems[0].Text.CompareTo("Miscellaneous Text 1") == 0) //misc text 1
{
this.AddMiscellaneousText(section, ptControlLocation, "Miscellaneous Text 1");
}
else if (lv.SelectedItems[0].Text.CompareTo("Miscellaneous Text 2") == 0) //misc text 2
{
this.AddMiscellaneousText(section, ptControlLocation, "Miscellaneous Text 2");
}
else if (lv.SelectedItems[0].Text.CompareTo("Miscellaneous Text 3") == 0) //misc text 3
{
this.AddMiscellaneousText(section, ptControlLocation, "Miscellaneous Text 3");
}
else //unknown object
{
MessageBox.Show("Unknown object. Please add code to process this object.");
}
//clear ListView selection
this.lvCustomItems.SelectedItems.Clear();
}
}
} |
| Visual Basic | Copy Code |
|---|
Private Sub arDesigner_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles arDesigner.DragDrop
If e.Data.GetData(GetType(System.Windows.Forms.ListView)) Is Me.lvCustomItems Then
Dim lv As System.Windows.Forms.ListView = e.Data.GetData(GetType(System.Windows.Forms.ListView))
Dim section As DataDynamics.ActiveReports.Section = Me.arDesigner.SectionAt(New Point(e.X, e.Y))
If section Is Nothing Then
MessageBox.Show("Please drop items only on visible area of report surface.", _
Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
Dim ptDesigner As Point = Me.arDesigner.PointToClient(New Point(e.X, e.Y))
Dim ptSection As Point = Me.arDesigner.PointToSection(section, ptDesigner)
Dim ptControlLocation As PointF = New PointF(ptSection.X / Me.arDesignerDpiX, ptSection.Y / Me.arDesignerDpiY)
If lv.SelectedItems(0).Text.CompareTo("Logo") = 0 Then
Me.AddLogo(section, ptControlLocation)
ElseIf lv.SelectedItems(0).Text.CompareTo("Disclaimer") = 0 Then
Me.AddDisclaimer(section, ptControlLocation)
ElseIf lv.SelectedItems(0).Text.CompareTo("Miscellaneous Text 1") = 0 Then
Me.AddMiscellaneousText(section, ptControlLocation, "Miscellaneous Text 1")
ElseIf lv.SelectedItems(0).Text.CompareTo("Miscellaneous Text 2") = 0 Then
Me.AddMiscellaneousText(section, ptControlLocation, "Miscellaneous Text 2")
ElseIf lv.SelectedItems(0).Text.CompareTo("Miscellaneous Text 3") = 0 Then
Me.AddMiscellaneousText(section, ptControlLocation, "Miscellaneous Text 3")
Else
MessageBox.Show("Unknown object. Please add code to process this object.")
End If
Me.lvCustomItems.SelectedItems.Clear()
End If
End Sub |
See Also