使用webbrowser封装一个浏览器的心得

1.如何在程序中使用Ping
csharp
public bool Ping(string ip)
{
System.Net.NetworkInformation.Ping p = new System.Net.NetworkInformation.Ping();
System.Net.NetworkInformation.PingOptions options = new System.Net.NetworkInformation.PingOptions();
options.DontFragment = true;
string data = "Test Data!";
byte[] buffer = Encoding.ASCII.GetBytes(data);
int timeout = 1000; // Timeout 时间,单位:毫秒
System.Net.NetworkInformation.PingReply reply = p.Send(ip, timeout, buffer, options);
if (reply.Status == System.Net.NetworkInformation.IPStatus.Success)
return true;
else
return false;
}

2.如何设置父窗体,让子窗体居中并在父窗体之上
[DllImport(“user32”)]
public static extern int SetParent(int hWndChild, int hWndNewParent);

Signform.Show();
SetParent((int)Signform.Handle, (int)this.Handle);
3.如何把所有的dll,exe打包成一个对外的exe文件
ilmerge:过期,很久未更新
Costura.Fody:http://www.cnblogs.com/war-hzl/p/7483912.html
4.怎样能使winform窗体的大小固定住,不能调整其大小
窗体FormBorderStyle属性设置为:FixedSingle,再把最大化禁用就可以了
5.如何把Button设为透明的方法:
修改 FlatAppearance属性下的BorderSize 为0
修改 FlatStyle 的属性为 Flat
再把Text值设为空就行了。
6.如何使用用户不能拖动窗体:
FormBorderStyle:none
7.如何在C# winForm中MenuStrip中的添加子菜单事件
“`csharp
private void Form1_Load(object sender, EventArgs e)
{
//创建MenuStrip对象
MenuStrip MS = new MenuStrip();
//创建一个ToolStripMenuItem菜单,可以文本和图片一并添加
ToolStripMenuItem tsmi = new ToolStripMenuItem(“测试按钮”);
//绑定菜单的点击事件
tsmi.Click+=DemoClick;
//创建子菜单 可以文本和图片一并添加
ToolStripMenuItem tsmi2 = new ToolStripMenuItem(“测试子按钮”);
//绑定子菜单点击事件
tsmi2.Click += DemoClick;
//添加子菜单/二级菜单
tsmi.DropDownItems.Add(tsmi2);
//添加主菜单
MS.Items.Add(tsmi);
//界面显示
this.Controls.Add(MS);
}

//自己定义个点击事件需要执行的动作
private void DemoClick(object sender, EventArgs e)
{
ToolStripMenuItem but = sender as ToolStripMenuItem;
MessageBox.Show(but.Text);
}
“`
8.”Could not load file or assembly ‘Newtonsoft.Json'”
一种可能是dll版本不对,
第二种可能是项目引用了bin目录下的dll
解决:单独在项目外添加lib目录,或者使用nuget
9.如何隐藏tab标签:https://www.cnblogs.com/happylyyer/p/4305998.html
10.如何打包时覆盖:https://www.cnblogs.com/chechen/p/6252965.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值