Symptom
Windows form viewer always defaults to the page area of the report and it highlights a dotted line around the page. There is no way to change that focus unless an event is called. But same thing as clicking on the Main Report Tab, any click removes the highlighting.
Environment
SAP Crystal Reports, developer version for Microsoft Visual Studio SP12
Resolution
Install Service Pack 13 or above, we always suggest using the latest SP.
InitialFocus is added into the Focus Properties of CrystalReportViewer. And there are 6 options below.
New behaviour:
|
Comment |
ToolBar |
ToolBar is focused |
PageAlbumTab |
PageAlbumTab is focused |
Page |
Original behavior, default option |
PageObject |
Select the report object according to “InitialSectionIndex” & “InitialObjectIndex” |
GroupTree |
Only focused when GroupTree is selected in “ToolPanelView” |
ParameterPanel |
Only focused when ParameterPanel is selected in “ToolPanelView” |
As for “InitialSectionIndex” & “InitialObjectIndex”:
- Become effective when “PageObjet” is selected;
- The default value “0”, “0”, focus on the first page object initially;
- InitialSectionIndex/InitialObjectIndex("-1", "-1") is as same as “Page”
Notice: If one section is empty, it still has the index. And the next not empty section will be focused.\
SectionIndex and ObjectIndex can be any number. The logic of exception handling is shown as follows:
|
Focused Object |
SectionIndex is valid, ObjectIndex is valid |
The valid object |
SectionIndex is invalid, ObjectIndex is valid |
The whole page (dotted line) is highlighted |
SectionIndex is valid, ObjectIndex is invalid |
The first object of this section |
SectionIndex is invalid, ObjectIndex is invalid |
The whole page (dotted line) is highlighted |
Current SectionIndex is empty (no object in current section) |
The ObjectIndex of the next not empty section |
Code sample in C#:
// if no groups in report hide the group tree in viewer
if (rptClientDoc.DataDefController.DataDefinition.Groups.Count == 0)
{
crystalReportViewer1.SetFocusOn(UIComponent.Page);
crystalReportViewer1.ToolPanelView = ToolPanelViewType.None;
}
else
{
/// this sets the focus on the group set to none and then sets it to the group again to get rid of the dotted line around the main viewer area.
crystalReportViewer1.ToolPanelView = ToolPanelViewType.None;
crystalReportViewer1.SetFocusOn(UIComponent.GroupTree);
crystalReportViewer1.ToolPanelView = ToolPanelViewType.GroupTree;
crystalReportViewer1.SetFocusOn(UIComponent.GroupTree);
}
Note: clicking on the page section will show the dotted line the first time you click.
Keywords
CR.NET Winform Viewer; InitialFocus; SetFocus; dotted line , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem