英文:
Why the usercontrol size is changing each time i'm dragging the control over form1 designer?
问题
在Form1设计器中拖动UserControl后,我尝试在其上更改UserControl的大小,但当我拖动UserControl时,UserControl的大小会发生变化。
以下是两个截图,显示了每次我拖动UserControl时UserControl的大小。
UserControl是地图。
当我按住鼠标在UserControl上时,它是实际大小的:
一旦我松开鼠标左键,不再按住它,UserControl的大小在UserControl设计器上发生了变化,我可以看到UserControl的实际大小,但大部分是空的,地图内部现在较小:
UserControl的代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DotNetBrowser.Browser;
using DotNetBrowser.Engine;
using DotNetBrowser.WinForms;
namespace Weather
{
public partial class GoogleMapsUserControl : UserControl
{
public static IBrowser browser;
public static IEngine engine;
public GoogleMapsUserControl()
{
InitializeComponent();
engine = EngineFactory.Create(new EngineOptions.Builder
{
LicenseKey = "KEY HERE"
}.Build());
// 创建和初始化IEngine
// engine = EngineFactory.Create();
// 创建Windows Forms BrowserView控件
BrowserView browserView = new BrowserView()
{
Dock = DockStyle.Fill
};
// 创建IBrowser
browser = engine.CreateBrowser();
browser.Navigation.LoadProgressChanged += Navigation_LoadProgressChanged;
browser.Navigation.LoadFinished += Navigation_LoadFinished;
browser.Navigation.LoadUrl("D:\\Csharp Projects\\Weather\\map.html");
// 从Browser初始化Windows Forms BrowserView控件
browserView.InitializeFrom(browser);
this.Controls.Add(browserView);
}
private void Navigation_LoadProgressChanged(object sender, DotNetBrowser.Navigation.Events.LoadProgressChangedEventArgs e)
{
}
private void Navigation_LoadFinished(object sender, DotNetBrowser.Navigation.Events.LoadFinishedEventArgs e)
{
}
private void GoogleMapsUserControl_Load(object sender, EventArgs e)
{
}
}
}
英文:
once I dragged the usercontrol to form1 designer.
then I tried to change the usercontrol size while it's on form1 designer but then when I drag the usercontrol around the usercontrol size is changing.
here are two screenshots showing the usercontrol size each time I'm dragging it.
the usercontrol is the map.
when I hold down the mouse on the usercontrol it's in its actual size:
once I leave the mouse left button and not holding it down the size of the usercontrol has changed on the usercontrol designer I can see the usercontrol actual size but most of is empty the map inside is now smaller:
the user control code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DotNetBrowser.Browser;
using DotNetBrowser.Engine;
using DotNetBrowser.WinForms;
namespace Weather
{
public partial class GoogleMapsUserControl : UserControl
{
public static IBrowser browser;
public static IEngine engine;
public GoogleMapsUserControl()
{
InitializeComponent();
engine = EngineFactory.Create(new EngineOptions.Builder
{
LicenseKey = "KEY HERE"
}.Build());
// Create and initialize the IEngine
//engine = EngineFactory.Create();
// Create the Windows Forms BrowserView control
BrowserView browserView = new BrowserView()
{
Dock = DockStyle.Fill
};
// Create the IBrowser
browser = engine.CreateBrowser();
browser.Navigation.LoadProgressChanged += Navigation_LoadProgressChanged;
browser.Navigation.LoadFinished += Navigation_LoadFinished;
browser.Navigation.LoadUrl("D:\\Csharp Projects\\Weather\\map.html");
// Initialize the Windows Forms BrowserView control
browserView.InitializeFrom(browser);
this.Controls.Add(browserView);
}
private void Navigation_LoadProgressChanged(object sender, DotNetBrowser.Navigation.Events.LoadProgressChangedEventArgs e)
{
}
private void Navigation_LoadFinished(object sender, DotNetBrowser.Navigation.Events.LoadFinishedEventArgs e)
{
}
private void GoogleMapsUserControl_Load(object sender, EventArgs e)
{
}
}
}
答案1
得分: 1
我认为你已经将地图用户控件拖到了“下载”组合框内,所以地图被组合框的限制所“裁剪”。请将地图控件拖到组合框外,直接放在窗体上。
在GroupBox内放置ListView的示例:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论