把一个WEBBROWSER放在一个PANNEL里,如何实现webbrowser 拖动呢
解决方案 »
- CWE-759: Use of a One-Way Hash without a Salt
- C# winfrom 页面传值
- 怎么在内存中,将bmp转成jpg。
- 【急!!!】vs2010为什么老是报为将对象引用设置到对象的实例!!!
- DataGridView里怎么加Textbox控件
- 急求:C# WinForm,开机直接启动应用程序(WindowsApplication),不要XP系统的登录画面和桌面?
- 显示“命名空间并不直接包含诸如字段或方法之类的成员”,刚学不懂为什么错,求救!
- 如何判断一个窗体是否已经显示
- 关于Random的Next()成员函数问题
- 请问如何在C#打开如,ToolBarImages.resources
- 小菜鸟刚接触wcf 哪位大虾进来指点指点,在线等啊
- WEB中如何生成并打印条形码
1、将webbrowser放在panle中,设置webbrowser.Dock为Fill
2、或者设置webbrowser的Anchor属性为上下左右铆定。
//
// panel6
//
this.panel6.Controls.Add(this.webBrowser1);
this.panel6.Location = new System.Drawing.Point(294, 8);
this.panel6.Name = "panel6";
this.panel6.Size = new System.Drawing.Size(435, 254);
this.panel6.TabIndex = 2;
this.panel6.MouseDown += new System.Windows.Forms.MouseEventHandler(this.MyMouseDown);
this.panel6.MouseLeave += new System.EventHandler(this.MyMouseLeave);
this.panel6.MouseMove += new System.Windows.Forms.MouseEventHandler(this.MyMouseMove);
this.panel6.Resize+= new System.EventHandler(this.panel6_Resize);
this.panel6.LocationChanged += new EventHandler(this.panel6_Resize);
//
// webBrowser1
//
this.webBrowser1.Location = new System.Drawing.Point(31, 19);
this.webBrowser1.MinimumSize = new System.Drawing.Size(20, 20);
this.webBrowser1.Name = "webBrowser1";
this.webBrowser1.Size = new System.Drawing.Size(315, 209);
this.webBrowser1.TabIndex = 0;
this.webBrowser1.Url = new System.Uri("http://www.sina.com.cn", System.UriKind.Absolute);
void panel6_Resize(object sender, System.EventArgs e)
{
setWebbrowserSize();
} void setWebbrowserSize()
{
Panel p = this.panel6;
int x = p.Location.X;
int y = p.Location.Y;
if (p.HasChildren && p.Controls.Count == 1)
{
WebBrowser awebbrowser = (WebBrowser)p.Controls[0];
awebbrowser.Location = new Point(x + 2, y + 2);
awebbrowser.Size = new Size(p.Size.Width - 6, p.Size.Height - 6); }
}
{
Panel p = this.panel6;
int x = p.Location.X;
int y = p.Location.Y;
if (p.HasChildren && p.Controls.Count == 1)
{
WebBrowser awebbrowser = (WebBrowser)p.Controls[0];
awebbrowser.Location = new Point(x + 2, y + 2);
awebbrowser.Size = new Size(p.Size.Width - 6, p.Size.Height - 6); }
为什么我在FORM_LOAD中调用此函数,Webbrowser中位置却不对呢,差不多在PANEL的右半边,离左边框远远不止2
awebbrowser.Location = new Point(2, 2);//(x + 2, y + 2);