发明
博客园
首页
新闻
新随笔
联系
管理
订阅
随笔- 8 文章- 0 评论- 20
2007年7月29日
C/C++ 字符编码的转换(ut8、gb2312)
posted @ 2007-07-29 12:20 戏梦 阅读(3423) 评论(3)
编辑
2007年2月14日
大家春节快乐!!携手共进
忙了一年了,终于可以好好的休息下了..
大家春节快乐、身体键康!
呵呵~~~~~~~~~~~
新的一年到来,我们一起努力
创造未来,携手共进。。。。
posted @ 2007-02-14 10:48 戏梦 阅读(59) 评论(0)
编辑
2007年1月11日
自己写的Pircture的绑定控件(VB.net)
Pircture的绑定控件
Public Class BindingPictureBoxClass BindingPictureBox
Inherits System.Windows.Forms.PictureBox
Protected Overrides Sub OnPaint()Sub OnPaint(ByVal pe As System.Windows.Forms.PaintEventArgs)
If Not IsNothing(Me.Image) Then
Dim Width As Integer
=
Me.Image.Width
Dim heigh As Integer
=
Me.Image.Height
Dim nWidth, nHeigh, posx, posy As Integer
Dim p As Double
=
Me.Width
/
Me.Height
If (Width
/
heigh)
>
p Then
nWidth
=
Me.Width
nHeigh
=
Convert.ToInt32(Me.Width
/
Width
*
heigh)
Else
nHeigh
=
Me.Height
nWidth
=
Convert.ToInt32(Me.Height
/
heigh
*
Width)
End If
posx
+=
(CInt(Me.Width
-
nWidth)
/
2
)
posy
+=
(CInt(Me.Height
-
nHeigh)
/
2
)
pe.Graphics.DrawImage(Me.Image, posx, posy, nWidth, nHeigh)
End If
End Sub
Public Property ImageMember()Property ImageMember() As Object
Get
If IsNothing(Me.Image) Then
Return DBNull.Value
Else
Dim img As Image
=
Me.Image
Dim ST As New IO.MemoryStream
Dim RD As New IO.BinaryReader(ST)
img.Save(ST, Imaging.ImageFormat.Jpeg)
Dim buff As [Byte]()
=
ST.ToArray
ST.Close()
If buff.Length
>
1
Then
Return buff
Else
Return (DBNull.Value)
End If
End If
End Get
Set(ByVal Value As Object)
If Not IsDBNull(Value) Then
Dim Buff As [Byte]()
=
CType(Value, Byte())
If Buff.Length
>
1
Then
Dim ST As IO.MemoryStream
=
New IO.MemoryStream(Buff)
Me.Image
=
Image.FromStream(ST)
Me.Invalidate()
ST
=
Nothing
End If
Else
Me.Image
=
Nothing
Me.Invalidate()
End If
End Set
End Property
End Class
posted @ 2007-01-11 11:17 戏梦 阅读(108) 评论(0)
编辑
输入汉字获得拼音(C#)
posted @ 2007-01-11 11:03 戏梦 阅读(623) 评论(2)
编辑
输入汉字获得拼音(VB.net)
posted @ 2007-01-11 10:54 戏梦 阅读(1509) 评论(11)
编辑
2006年11月17日
asp.net 动态加载用户控件注意
在asp.net 动态加载用户控件时要注意:
在没加载成功是不能对它设置属性的,以免带来不别要的错误!!
代码如下:
Default.aspx
1
using
System;
2
using
System.Data;
3
using
System.Configuration;
4
using
System.Web;
5
using
System.Web.Security;
6
using
System.Web.UI;
7
using
System.Web.UI.WebControls;
8
using
System.Web.UI.WebControls.WebParts;
9
using
System.Web.UI.HtmlControls;
10
using
System.Drawing;
11
public
partial
class
_Default : System.Web.UI.Page
12
{
13
14
15
16
protected
void
Page_Load(
object
sender, EventArgs e)
17
{
18
19
20
Control control
=
LoadControl(
"
~/myControl.ascx
"
);
//
加载用户控件
21
this
.Panel1.Controls.Add(control);
//
把它添加到该面板中
22
23
24
myControl myC
=
control
as
myControl;
//
获得实例
25
if
(myC
==
null
)
//
是否用户控件加载成功
26
{
27
PartialCachingControl pcc
=
control
as
PartialCachingControl;
28
if
(pcc
!=
null
) myC
=
pcc.CachedControl
as
myControl;
29
}
30
if
(myC
!=
null
) myC.BackColor
=
Color.Yellow;
//
成功设置该控件的样式
31
32
33
}
34
}
35
myControl.ascx
1
using
System;
2
using
System.Data;
3
using
System.Configuration;
4
using
System.Collections;
5
using
System.Web;
6
using
System.Web.Security;
7
using
System.Web.UI;
8
using
System.Web.UI.WebControls;
9
using
System.Web.UI.WebControls.WebParts;
10
using
System.Web.UI.HtmlControls;
11
using
System.Drawing;
12
13
public
partial
class
myControl : System.Web.UI.UserControl
14
{
15
public
Color BackColor
16
{
17
get
{
return
TextBox1.BackColor; }
18
set
{ TextBox1.BackColor
=
value; }
19
}
20
21
protected
void
Page_Load(
object
sender, EventArgs e)
22
{
23
TextBox1.Text
=
DateTime.Now.ToLongTimeString();
24
}
25
26
protected
void
Button1_Click(
object
sender, EventArgs e)
27
{
28
this
.TextBox2.Text
=
this
.TextBox1.Text;
29
}
30
}
31
posted @ 2006-11-17 16:14 戏梦 阅读(670) 评论(0)
编辑
asp.net 操作xml
asp.net 对xml文件的读写,添加,修改,删除操作
下面有代码调试正确
using
System;
using
System.Collections;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Web;
using
System.Web.SessionState;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.HtmlControls;
using
System.Xml;
private
XmlDocument xmlDoc;
//
load xml file
private
void
LoadXml()
{
xmlDoc
=
new
XmlDocument();
xmlDoc.Load(Server.MapPath(
"
User.xml
"
));
}
//
添加节点
private
void
AddElement()
{
LoadXml();
XmlNode xmldocSelect
=
xmlDoc.SelectSingleNode(
"
user
"
);
XmlElement el
=
xmlDoc.CreateElement(
"
person
"
);
//
添加person节点
el.SetAttribute(
"
name
"
,
"
风云
"
);
//
添加person节点的属性"name"
el.SetAttribute(
"
sex
"
,
"
女
"
);
//
添加person节点的属性 "sex"
el.SetAttribute(
"
age
"
,
"
25
"
);
//
添加person节点的属性 "age"
XmlElement xesub1
=
xmlDoc.CreateElement(
"
pass
"
);
//
添加person节点的里的节点
xesub1.InnerText
=
"
123
"
;
//
设置文本节点
el.AppendChild(xesub1);
XmlElement xesub2
=
xmlDoc.CreateElement(
"
Address
"
);
xesub2.InnerText
=
"
昆明
"
;
//
设置文本节点
el.AppendChild(xesub2);
xmldocSelect.AppendChild(el);
xmlDoc.Save(Server.MapPath(
"
user.xml
"
));
}
//
修改节点
private
void
UpdateElement()
{
LoadXml();
XmlNodeList nodeList
=
xmlDoc.SelectSingleNode(
"
user
"
).ChildNodes;
//
获取bookstore节点的所有子节点
foreach
(XmlNode xn
in
nodeList)
//
遍历所有子节点
{
XmlElement xe
=
(XmlElement)xn;
//
将子节点类型转换为XmlElement类型
if
(xe.GetAttribute(
"
name
"
)
==
"
风云
"
)
//
如果name属性值为“风云”
{
xe.SetAttribute(
"
name
"
,
"
发明
"
);
//
如果下面有子节点在下走
XmlNodeList nls
=
xe.ChildNodes;
//
继续获取xe子节点的所有子节点
foreach
(XmlNode xn1
in
nls)
//
遍历
{
XmlElement xe2
=
(XmlElement)xn1;
//
转换类型
if
(xe2.Name
==
"
pass
"
)
//
如果找到
{
xe2.InnerText
=
"
66666
"
;
//
则修改
break
;
}
}
break
;
}
}
xmlDoc.Save(Server.MapPath(
"
user.xml
"
));
//
保存
}
//
删出节点
private
void
deleteNode()
{
LoadXml();
XmlNodeList xnl
=
xmlDoc.SelectSingleNode(
"
user
"
).ChildNodes;
foreach
(XmlNode xn
in
xnl)
{
XmlElement xe
=
(XmlElement)xn;
if
(xe.GetAttribute(
"
name
"
)
==
"
发明
"
)
{
//
xe.RemoveAttribute("name");
//
删除name属性
// xe.RemoveAll();
//
删除该节点的全部内容
xe.ParentNode.RemoveChild(xe);
break
;
}
}
xmlDoc.Save(Server.MapPath(
"
user.xml
"
));
//
保存
}
private
void
showIt()
{
LoadXml();
XmlNode xn
=
xmlDoc.SelectSingleNode(
"
user
"
);
XmlNodeList xnl
=
xn.ChildNodes;
foreach
(XmlNode xnf
in
xnl)
{
XmlElement xe
=
(XmlElement)xnf;
//
Console.WriteLine(xe.GetAttribute("name"));
//
显示属性值
//
Console.WriteLine(xe.GetAttribute("sex"));
//
//
XmlNodeList xnf1=xe.ChildNodes;
//
foreach(XmlNode xn2 in xnf1)
//
{
//
Console.WriteLine(xn2.InnerText);
//
显示子节点点文本
//
}
}
}
Xml的样式:
<?
xml version="1.0" encoding="gb2312"
?>
<
user
>
<
person
>
</
person
>
<
person
name
="风拉"
sex
="男"
age
="25"
>
<
pass
>
123
</
pass
>
<
Address
>
大明
</
Address
>
</
person
>
<
person
name
="风云"
sex
="女"
age
="25"
>
<
pass
>
123
</
pass
>
<
Address
>
昆明
</
Address
>
</
person
>
</
user
>
posted @ 2006-11-17 11:22 戏梦 阅读(5580) 评论(0)
编辑
2006年11月15日
开心
呵呵~~~
终于注册近来了,和大家一起学习交流..
posted @ 2006-11-15 20:51 戏梦 阅读(103) 评论(4)
编辑
仅列出标题
公告
昵称:
戏梦
园龄:
5年2个月
粉丝:
3
关注:
0
<
2012年2月
>
日
一
二
三
四
五
六
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
1
2
3
4
5
6
7
8
9
10
搜索
常用链接
我的随笔
我的评论
我的参与
最新评论
我的标签
更多链接
随笔分类
asp.net(2)
(rss)
C#(1)
(rss)
C/C++(1)
(rss)
vb.net(2)
(rss)
心情故事(2)
(rss)
随笔档案
2007年7月 (1)
2007年2月 (1)
2007年1月 (3)
2006年11月 (3)
文章分类
asp.net
(rss)
vs2005
(rss)
最新评论
阅读排行榜
评论排行榜
推荐排行榜