on 08-05-2023 4:42 PM
In my testing, none of the possible values for the InitialFocus property of the .NET Crystal Viewer Control can get rid of the initial dotted gray border indicating the page margins (see image below). The user has to manually click inside the page to select another object or click outside on a different control to get rid of that border.
That property was added (thanks to Don Williams) in response to a similar question years ago.
Has anyone managed to get rid of that border on initial preview? If so, how?
Hi Ido,
Soda suggested this:
Just added below code in InitializeComponent
this.crystalReportViewer1.InitialFocus = CrystalDecisions.Windows.Forms.UIComponent.ToolBar;
Then it will not set the focus on the report page content, but on the toolbar.
I tried it and it does work.
Also I changed the check if Count - 0 to and AND and not an OR
// if no groups in report hide the group tree in viewer
if (rptClientDoc.DataDefController.DataDefinition.Groups.Count == 0 && rptClientDoc.DataDefController.DataDefinition.ParameterFields.Count == 0)
{
crystalReportViewer1.InitialFocus = CrystalDecisions.Windows.Forms.UIComponent.ToolBar;
//crystalReportViewer1.SetFocusOn(UIComponent.Page);
//crystalReportViewer1.ToolPanelView = ToolPanelViewType.ParameterPanel;
//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.ParameterPanel;
crystalReportViewer1.SetFocusOn(UIComponent.ParameterPanel);
//crystalReportViewer1.ToolPanelView = ToolPanelViewType.GroupTree;
//crystalReportViewer1.SetFocusOn(UIComponent.GroupTree);
//crystalReportViewer1.ToolPanelView = ToolPanelViewType.None;
//crystalReportViewer1.SetFocusOn(UIComponent.ParameterPanel);
}
Have a great day
Don
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, Don.
Since it works for you, I'll mark it as solved.
Perhaps it's a question of method call timing the calls but for me even that variation doesn't work.
Also, it makes no sense that a control property exposed through the designer for the control has to be called in code in unexpected places. It should work either by simply setting the property in the designer or by setting it once in the parent form load event.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, Don, but that still doesn't work in my testing.
Again, let's drop this. It's not worth chasing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ido,
You are correct, using my code doesn't work if you don't have a Group or Parameter in the report.
So the trick is to turn it on and then off and then it works, not really a direct fix but more of a way to get around it.
// if no groups in report hide the group tree in viewer
if (rptClientDoc.DataDefController.DataDefinition.Groups.Count == 0 || rptClientDoc.DataDefController.DataDefinition.ParameterFields.Count == 0)
{
crystalReportViewer1.SetFocusOn(UIComponent.Page);
crystalReportViewer1.ToolPanelView = ToolPanelViewType.ParameterPanel;
crystalReportViewer1.ToolPanelView = ToolPanelViewType.None;
}
Note you do see the Group/Parameter tree show up and then go away so you could handle it differently if that's not "nice" enough for you or try using the GroupPanel and see if that works better.
Have fun
Don
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ido,
Try this to set the focus on another part of the page:
// 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.ParameterPanel;
crystalReportViewer1.SetFocusOn(UIComponent.ParameterPanel);
//crystalReportViewer1.ToolPanelView = ToolPanelViewType.GroupTree;
//crystalReportViewer1.SetFocusOn(UIComponent.GroupTree);
}
Have fun
Don
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.