I followed the getting started tutorial for WinForms (https://dotnetbrowser.support.teamdev.com/support/solutions/articles/9000056958-quick-start-guide-for-winforms-developers).
I am using VS 2017 and .NET 4.6.1
Everything works great, but the browser window within the form is opening in a tiny window (approximately 50px square) with scrollbars and not taking up the full form. I've been scanning SO questions and the documentation and haven't found anyone reporting this before and I have not been able to understand how to configure this. Are there parameters for placing the control?
I tried using the 'UpdateSize' method, but that does not seem to do anything.
Has anyone else encountered this issue?
Hopefully this is a simple fix.
Thanks! Aaron
I figured it out. The BrowserView must be cast to a Control which then exposes many additional WinForm control properties such as DockStyle.
BrowserView browserView = new WinFormsBrowserView(BrowserFactory.Create();
Control browserWindow = (Control)browserView;
browserWindow.Dock = DockStyle.Fill;
Controls.Add(browserWindow);
In DotNetBrowser 1.16 and earlier versions WinFormsBrowserView.Dock property was set to DockStyle.Fill value by default.
In DotNetBrowser 1.17 and higher this property is set to DockStyle.None value by default.
Using the latest 1.19.1 even after replacing references multiple times.
WinFormsBrowserView does not show the .Dock property
Able to work around using this:
Public browser As Browser
Public browserView As BrowserView
browser = BrowserFactory.Create(BrowserType.HEAVYWEIGHT)
browserView = New WinFormsBrowserView(browser)
'browserView.dock = DockStyle.Fill '--this will not work so instead:
Dim obj As Control '--or Object
obj = browserView
obj.dock = DockStyle.Fill
If Controls.Contains(browserView) = False Then
'Controls.Add(browserView) '--Before
Controls.Add(obj) '--Now
There has to be a better solution. Please educate me.
Related
I'm using VS2010 and Crystal reports 13.
Is there any way to collapse/hide the group tree box that appears on the left hand side of my generated report? I saw a couple of proposed solutions but none seem to work for me.
Thanks in advance.
There also is a property on report viewer you can set as follows:
yourViewer.ToggleSidePanel = Constants.SidePanelKind.None;
I think this is a bit safer in case the Crystal Reports team decides to rename that button.
I finally found a solution that works, by manually finding the side panel and then hiding it:
var sidepanel = crystalReportsViewer1.FindName("btnToggleSidePanel") as ToggleButton;
if (sidepanel != null) {
crystalReportsViewer1.ViewChange += (x, y) => sidepanel.IsChecked = false;
}
adding this namespace:
using System.Windows.Controls.Primitives;
The problem was that the WPF ReportViewer is slightly diferent to the Win Forms one, some properties (such as ToolPanelView and ShowGroupTreeButton) have been removed, I tried many different things but the above was the only that did the trick.
You can change it from the designer by changing the 'ToolPanelView' to 'None' and hide the button by changing 'ShowGroupTreeButton' to 'false'. Previous versions had a method to explicitly hide the group tree but I believe it's been deprecated in the version you are using. To change the properties in code behind:
crystalreportviewer.ToolPanelView = TooPanelViewType.None;
crystalreportviewer.ShowGroupTreeButton = false;
there is a property DisplayGroupTree . and you can avoid the free space by using this code
CrystalReportViewer1.DisplayGroupTree = false;
CrystalReportViewer1.HasToggleGroupTreeButton = false;
Use the command to hide the panel.
CrystalReportViewer1.ToolPanelView = CrystalDecisions.Windows.Forms.ToolPanelViewType.None
I ran into the same issue as Crystal Report changes the convention. In older version of the Crystal report would hide the button and not show the panel on the left hand side.
CrystalReportViewer1.ShowGroupTreeButton = False
<Viewer:CrystalReportsViewer ToggleSidePanel="None"/>
Use the following properties in your webpage:
- ToolPanelView="None"
- HasToggleGroupTreeButton="false"
<CR:CrystalReportViewer ID="CRViewer" runat="server" HasCrystalLogo="False" ToolPanelView="None" HasToggleGroupTreeButton="false" BestFitPage="True" AutoDataBind="true" />
Group tree panel and its toggle will be hidden. It works well in my environment - ASP.Net 4.0, Crystal Report version 13.0.13
For asp.net
CrystalReportViewer1.ToolPanelView=CrystalDecisions.Web.ToolPanelViewType.None;
My windows forms application hosts AvalonEdit (the composite WPF control in question) in one of its forms to cater to its text editing requirements. Here's the code I use:
WPFHost = gcnew ElementHost();
TextField = gcnew AvalonEdit::TextEditor();
WPFHost->Dock = DockStyle::Fill;
WPFHost->Child = TextField;
TextField->Options->AllowScrollBelowDocument = false;
TextField->Options->EnableEmailHyperlinks = false;
TextField->Options->EnableHyperlinks = true;
TextField->Options->RequireControlModifierForHyperlinkClick = true;
TextField->ShowLineNumbers = true;
ContainerControl->Controls->Add(WPFHost); // the container is a panel
The code compiles and executes fine, except for the scrollbars - http://dl.dropbox.com/u/2584752/avalonEditBug.png . Right clicking on what's left of the bar raises an ArgumentOutOfRange exception.
Strangely, I wasn't able to reproduce the issue when I tried hosting the control in a newly created sample project. 'mI using the latest build of the text editor and have all the requisite assemblies installed.
EDIT: Wrapping the editor in a usercontrol doesn't help either.
You say that the control works fine in a new/blank project but fails in the one you need makes me wonder about conflicts more than anything. In the project you're really wanting compared to the project it worked in what are the differences? .NET version? Referencing an assembly from a directory in one but out of the GAC in another?
It's hard to say that the control is messing up for you when you've got it working elsewhere, so the only thing I can suggest is just dive deep into the differences of the two projects.
Good luck.
This looks like a layout error to me. Maybe WPFHost measures the TextField unexpectedly.
I can suggest setting specific Width and Height on the TextField itself. If this fixes the problem you can adjust those as the size of the WPFHost control changes or try setting the MaxHeight/Width, sometimes they help and save some code for Width/Height updates.
try to create a WPF grid as a child of ElementHost, and place the editor inside that grid. On Other way, is to create an UserControl have the editor in that control and use the control inside your Winform app. Such approach helped me a couple of times.
I've implemented a workaround for the issue as mentioned in this thread [ Synchronizing a WPF ScrollViewer with a WinForms ScrollBar ].
when creating a simple VSPackage with a Tool Window a sample WPF user control is created and added to the Tool Window.
Must this user control be of WPF? i have a winforms user control and, when adding it to the tool window it's not getting displayed. tried hosting it in WPF with no success. is there any standard way of doing this?
I faced the same issue. Searched a lot. Was not able to find the answer or sample. Finally posted on msdn forum. Got my answer. Here is the link to the thread of msdn forum
MSDN Forum thread link
The ToolWindowPane can be used to host WPF content or a Winform control.
For a Winform control, you just need to override the Window property get, and leave the Content property null.
For example:
public MyToolWindow() : base(null)
{
this.Caption = Resources.ToolWindowTitle;
this.BitmapResourceID = 301;
this.BitmapIndex = 1;
control = new MyControl();
}
override public System.Windows.Forms.IWin32Window Window
{
get
{
return (System.Windows.Forms.IWin32Window)control;
}
}
I'm almost certain it can be winforms too, and I'm sure there's a demo somewhere on MSDN. I'll see if I can dig it up sometime.
I have created a single-instance application and want to activate an already opened window if the user starts the app multiple times. This works fine however I have the problem, that if the already opened window is beyond another applications window, I must bring it to front.
I have tried window.Focus() and window.Show() but both of them seem not to work. As a workaround I use …
bool oldTopMost = window.Topmost;
window.Topmost = true;
window.Topmost = oldTopMost;
window.Focus();
… this does the job but looks to me very ugly. Has anyone a better solution for this?
You could use Window.Activate instead:
window.Activate();
This is the WPF equivelent to calling SetForegroundWindow.
I am trying to send my dynamically created silverlight 2 page/image to a an ASP.net web service to render it as an bitmap image.
I can see many examples how to get the XAML using javascript (see here) in version 1 of silverlight but I have a few differences.
a) I am using silverlight 2 RC1
b) I have dynamically add controls to the page in c#
c) I would prefer to use c# to get the new XAML to keep all the coed in one place.
does anyone know how to extract the XAML from a control or the page in c#?
Thank you
Update: This is now possible under silverlight 3 using a writable bitmap to save the XAML as a JPEG see my blog post here: http://blog.blueboxes.co.uk/2009/07/21/rendering-xaml-to-a-jpeg-using-silverlight-3/
unfortunately there is not a method for a .ToXaml() on an element tree unfortunately. You can use VisualTreeHelper to build such a method and recurse through a particular element I suppose.
SilverlightContrib has a XamlWriter class that can extract the XAML from a live control.
It's free.
The link is: http://silverlightcontrib.org
The code would be something like:
// using SilverlightContrib.Xaml;
var cb = new GroupBox();
StringBuilder sb = new StringBuilder();
XamlWriterSettings settings = new XamlWriterSettings();
using (XamlWriter writer = XamlWriter.CreateWriter(sb, false, settings))
{
writer.WriteElement(cb);
}
string result = sb.ToString();