C#的ToolTip(delphi叫Hint)机制非常怪,不是像delphi的元件一样,每个TControl有一个Hint属性,C#有一个ToolTip元件,当把这个元件从工具箱拉到form上后,选中form上的任何control元件,在属性窗体(Object Inspector)上就会多出一个属性“toolTip1上的ToolTip”,如果多拉几个ToolTip元件到form上,就会多出现几个这样的属性“toolTip2上的ToolTip”,“toolTip3上的ToolTip”.......怪异,实在是怪异,不知道叫什么设计模式。查看ToolTip的函数,有两个GetTooTip(Control AControl),SetTooTip(Control AControl,string AToolTip),感觉TooTip元件就是一个Dictionary,但是没有属性来知道某个ToolTip元件为多少个Control设定了ToolTip字串。
另一个奇怪的是,ToolStripStatusLabel/ToolStripDropDownButton等元件比较特殊,他们却有一个ToolTipText属性,他们实现Hint的机制又不靠ToolTip元件。 ......
C#的ToolTip(delphi叫Hint)机制非常怪,不是像delphi的元件一样,每个TControl有一个Hint属性,C#有一个ToolTip元件,当把这个元件从工具箱拉到form上后,选中form上的任何control元件,在属性窗体(Object Inspector)上就会多出一个属性“toolTip1上的ToolTip”,如果多拉几个ToolTip元件到form上,就会多出现几个这样的属性“toolTip2上的ToolTip”,“toolTip3上的ToolTip”.......怪异,实在是怪异,不知道叫什么设计模式。查看ToolTip的函数,有两个GetTooTip(Control AControl),SetTooTip(Control AControl,string AToolTip),感觉TooTip元件就是一个Dictionary,但是没有属性来知道某个ToolTip元件为多少个Control设定了ToolTip字串。
另一个奇怪的是,ToolStripStatusLabel/ToolStripDropDownButton等元件比较特殊,他们却有一个ToolTipText属性,他们实现Hint的机制又不靠ToolTip元件。 ......
ASP.NET程序中常用的三十三种代码
1. 打开新的窗口并传送参数:
传送参数:
response.write("<script>window.open(’*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"’)</script>")
接收参数:
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
2.为按钮添加对话框
Button1.Attributes.Add("onclick","return confirm(’确认?’)");
button.attributes.add("onclick","if(confirm(’are you sure...?’)){return true;}else{return false;}")
3.删除表格选定记录
int intEmpID = (int)MyDataGrid.DataKeys[e.Item.ItemIndex];
string deleteCmd = "Delete from Employee where emp_id = " + intEmpID.ToString()
4.删除表格记录警告
private void DataGrid_ItemCreated(Object sender,DataGridItemEventArgs e)
{
switch(e.Item.ItemType)
{
case ListItemType.I ......
ASP.NET程序中常用的三十三种代码
1. 打开新的窗口并传送参数:
传送参数:
response.write("<script>window.open(’*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"’)</script>")
接收参数:
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
2.为按钮添加对话框
Button1.Attributes.Add("onclick","return confirm(’确认?’)");
button.attributes.add("onclick","if(confirm(’are you sure...?’)){return true;}else{return false;}")
3.删除表格选定记录
int intEmpID = (int)MyDataGrid.DataKeys[e.Item.ItemIndex];
string deleteCmd = "Delete from Employee where emp_id = " + intEmpID.ToString()
4.删除表格记录警告
private void DataGrid_ItemCreated(Object sender,DataGridItemEventArgs e)
{
switch(e.Item.ItemType)
{
case ListItemType.I ......
一、建立网页
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<script language="javascript" type="text/javascript">
<!-- 提供给C#程序调用的方法 -->
function messageBox(message)
{
alert(message);
}
</script>
</head>
<body>
<!-- 调用C#方法 -->
<button onclick="window.external.MyMessageBox('javascript访问C#代码')" >
javascript访问C#代码</button>
</body>
</html>
二、建立Windows应用程序
1. 创建Windows应用程序项目
2. 在Form1窗体中添加WebBrowser控件
3. 在Form1类的上方添加
[System.Runtime.InteropServices.ComVisibleAttribute(true)]
这是为了将该类设置为com可访问。如果不进行该声明将会出错。出错信息如下图所示:
如:
[System.Runtime.InteropServices.ComVisibleAttribute(true)]
public partial class Form1 : Form
4.初始化WebBrowser的Url与ObjectForScripting两个属性。
Url属性:WebBrowser控件显示的网页路径
ObjectForScripting属性:该对象可由显示在WebBrows ......
一、建立网页
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<script language="javascript" type="text/javascript">
<!-- 提供给C#程序调用的方法 -->
function messageBox(message)
{
alert(message);
}
</script>
</head>
<body>
<!-- 调用C#方法 -->
<button onclick="window.external.MyMessageBox('javascript访问C#代码')" >
javascript访问C#代码</button>
</body>
</html>
二、建立Windows应用程序
1. 创建Windows应用程序项目
2. 在Form1窗体中添加WebBrowser控件
3. 在Form1类的上方添加
[System.Runtime.InteropServices.ComVisibleAttribute(true)]
这是为了将该类设置为com可访问。如果不进行该声明将会出错。出错信息如下图所示:
如:
[System.Runtime.InteropServices.ComVisibleAttribute(true)]
public partial class Form1 : Form
4.初始化WebBrowser的Url与ObjectForScripting两个属性。
Url属性:WebBrowser控件显示的网页路径
ObjectForScripting属性:该对象可由显示在WebBrows ......
xml文件:
<?xml version="1.0" encoding="utf-8" ?>
<bookstore>
<book>
<title lang="eng">Harry Potter</title>
<price>29.99</price>
</book>
<book>
<title lang="eng">Learning XML</title>
<price>39.98</price>
</book>
<bookstore>
<title lang="eng">Learning C#</title>
<price>55.23</price>
</bookstore>
<item name="1">第一个item</item>
<item name="2">
<item name="1">这个结点(1)</item>
<item name="2">这个结点(2)</item>
<book>
<title lang="cn">Learni ......
xml文件:
<?xml version="1.0" encoding="utf-8" ?>
<bookstore>
<book>
<title lang="eng">Harry Potter</title>
<price>29.99</price>
</book>
<book>
<title lang="eng">Learning XML</title>
<price>39.98</price>
</book>
<bookstore>
<title lang="eng">Learning C#</title>
<price>55.23</price>
</bookstore>
<item name="1">第一个item</item>
<item name="2">
<item name="1">这个结点(1)</item>
<item name="2">这个结点(2)</item>
<book>
<title lang="cn">Learni ......
sd.xml文件:
<?xml version="1.0" encoding="gb2312"?>
<!--这是一个xml文件-->
<xml1>
<item name="1">第一个item</item>
<item name="2">
<item name="1">这个结点(1)</item>
</item>
</xml1>
cs操作代码:
protected void Page_Load(object sender, EventArgs e)
{
XmlTextReader reader = null;
try
{
reader = new XmlTextReader(Server.MapPath("sd.xml"));
reader ......
sd.xml文件:
<?xml version="1.0" encoding="gb2312"?>
<!--这是一个xml文件-->
<xml1>
<item name="1">第一个item</item>
<item name="2">
<item name="1">这个结点(1)</item>
</item>
</xml1>
cs操作代码:
protected void Page_Load(object sender, EventArgs e)
{
XmlTextReader reader = null;
try
{
reader = new XmlTextReader(Server.MapPath("sd.xml"));
reader ......
现在很多软件都是以xml文件作为数据源,而很多数据工具如pb等却只能另存为txt、excel等格式,为此需要一工具能将txt文本转换成xml文件。google了一下,没找到合适的,冲动之下用C#写了一个txt文本转xml格式文本的小程序,代码如下。
新建一个windows应用程序,命名该窗体为FrmTxtXml,在该窗体中添加:
一个按钮” toolStripOpen”,text为“打开文件”;
一个按钮” toolStripConvert”,text为“转换”;
一个按钮” toolStripSaveas”,text为“另存为”;
一个文本框” txtTXT”,显示txt文本;
一个文本框”txtXML5”,显示xml格式文本;
public partial class FrmTxtXml : Form
{
String txtContent = String ......
现在很多软件都是以xml文件作为数据源,而很多数据工具如pb等却只能另存为txt、excel等格式,为此需要一工具能将txt文本转换成xml文件。google了一下,没找到合适的,冲动之下用C#写了一个txt文本转xml格式文本的小程序,代码如下。
新建一个windows应用程序,命名该窗体为FrmTxtXml,在该窗体中添加:
一个按钮” toolStripOpen”,text为“打开文件”;
一个按钮” toolStripConvert”,text为“转换”;
一个按钮” toolStripSaveas”,text为“另存为”;
一个文本框” txtTXT”,显示txt文本;
一个文本框”txtXML5”,显示xml格式文本;
public partial class FrmTxtXml : Form
{
String txtContent = String ......