System.Environment.GetFolderPath(System.Environment.SpecialFolder.Favorites)
System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop)
更多请见枚举类
System.Environment.SpecialFolder
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add(“onmouseover”, “c=this.style.backgroundColor;this.style.backgroundColor=’#00ffee’;”);
e.Row.Attributes.Add(“onmouseout”, “this.style.backgroundColor=c”);
}
}
protected void GridView1_DataBound(object sender, EventArgs e)
{
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
string lbl = Convert.ToString(DataBinder.Eval(e.Row.DataItem,”CategoryName”));
if (lbl == “Produce”)
{
e.Row.BackColor = System.Drawing.Color.Beige;
}
}
}
序列化问题
[Serializable]
public class FatherClass {
private string id;
public string Id
{
get { return id;}
set { id = value; }
}
}
子类
[Serializable]
public class ChildClass : FatherClass
{
private string childname;
public string Childname
{
get { return childname; }
set { childname = value; }
}
}
WebService定义
[XmlInclude(typeof(FatherClass))]
[XmlInclude(typeof(ChildClass))]
[WebMethod]
public FatherClassHelloStus(FatherClass obj)
{
ChildClass child = (ChildClass)obj;
…. return child;
}
更多请见枚举类
System.Environment.SpecialFolder
通过.Net FrameWork 2.0下提供的“System.Net.Mail”可以轻松的实现,本文列举了3种途径来发送:
1.通过Localhost;
2.通过普通SMTP;
3.通过SSL的SMTP;
public void SendMailLocalhost()
{
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
msg.To.Add(“a@a.com“);
msg.To.Add(“b@b.com“);
/*
* msg.To.Add(“b@b.com”);
* msg.To.Add(“b@b.com”);
* msg.To.Add(“b@b.com”);可以发送给多人
*/
msg.CC.Add(“c@c.com“);
/*
* msg.CC.Add(“c@c.com”);
* msg.CC.Add(“c@c.com”);可以抄送给多人
*/
msg.From = new MailAddress(“a@a.com“, “AlphaWu“, System.Text.Encoding.UTF8);
/* 上面3个参数分别是发件人地址(可以随便写),发件人姓名,编码*/
msg.Subject = “这是测试邮件“;//邮件标题
msg.SubjectEncoding = System.Text.Encoding.UTF8;//邮件标题编码
msg.Body = “邮件内容“;//邮件内容
msg.BodyEncoding = System.Text.Encoding.UTF8;//邮件内容编码
msg.IsBodyHtml = false;//是否是HTML邮件
msg.Priority = MailPriority.High;//邮件优先级 
SmtpClient client = new SmtpClient();
client.Host = “localhost“;
object userState = msg;
try
{
client.SendAsync(msg, userState);
//简单一点儿可以client.Send(msg);
MessageBox.Show(“发送成功“);
}
catch (System.Net.Mail.SmtpException ex)
{
MessageBox.Show(ex.Message, “发送邮件出错“);
}
}
public void SendMailUseZj()
{
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
msg.To.Add(“a@a.com“);
msg.To.Add(“b@b.com“);
/*
* msg.To.Add(“b@b.com”);
* msg.To.Add(“b@b.com”);
* msg.To.Add(“b@b.com”);可以发送给多人
*/
msg.CC.Add(“c@c.com“);
/*
* msg.CC.Add(“c@c.com”);
* msg.CC.Add(“c@c.com”);可以抄送给多人
*/
msg.From = new MailAddress(“a@a.com“, “AlphaWu“, System.Text.Encoding.UTF8);
/* 上面3个参数分别是发件人地址(可以随便写),发件人姓名,编码*/
msg.Subject = “这是测试邮件“;//邮件标题
msg.SubjectEncoding = System.Text.Encoding.UTF8;//邮件标题编码
msg.Body = “邮件内容“;//邮件内容
msg.BodyEncoding = System.Text.Encoding.UTF8;//邮件内容编码
msg.IsBodyHtml = false;//是否是HTML邮件
msg.Priority = MailPriority.High;//邮件优先级 
SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential(“username@zj.com“, “userpass“);
//在zj.com注册的邮箱和密码
client.Host = “smtp.zj.com“;
object userState = msg;
try
{
client.SendAsync(msg, userState);
//简单一点儿可以client.Send(msg);
MessageBox.Show(“发送成功“);
}
catch (System.Net.Mail.SmtpException ex)
{
MessageBox.Show(ex.Message, “发送邮件出错“);
}
}
public void SendMailUseGmail()
{
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
msg.To.Add(“a@a.com“);
msg.To.Add(“b@b.com“);
/*
* msg.To.Add(“b@b.com”);
* msg.To.Add(“b@b.com”);
* msg.To.Add(“b@b.com”);可以发送给多人
*/
msg.CC.Add(“c@c.com“);
/*
* msg.CC.Add(“c@c.com”);
* msg.CC.Add(“c@c.com”);可以抄送给多人
*/
msg.From = new MailAddress(“a@a.com“, “AlphaWu“, System.Text.Encoding.UTF8);
/* 上面3个参数分别是发件人地址(可以随便写),发件人姓名,编码*/
msg.Subject = “这是测试邮件“;//邮件标题
msg.SubjectEncoding = System.Text.Encoding.UTF8;//邮件标题编码
msg.Body = “邮件内容“;//邮件内容
msg.BodyEncoding = System.Text.Encoding.UTF8;//邮件内容编码
msg.IsBodyHtml = false;//是否是HTML邮件
msg.Priority = MailPriority.High;//邮件优先级 
SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential(“username@gmail.com“, “password“);
//上述写你的GMail邮箱和密码
client.Port = 587;//Gmail使用的端口
client.Host = “smtp.gmail.com“;
client.EnableSsl = true;//经过ssl加密
object userState = msg;
try
{
client.SendAsync(msg, userState);
//简单一点儿可以client.Send(msg);
MessageBox.Show(“发送成功“);
}
catch (System.Net.Mail.SmtpException ex)
{
MessageBox.Show(ex.Message, “发送邮件出错“);
}
}
方法如下: Protected Overrides Function ProcessCmdKey(ByRef aoMsg As Message, ByVal aoKey As Keys) As Boolean If Me.ActiveControl.GetType.Name.Equals(“DataGridViewTextBoxEditingControl”) Then If aoKey = Keys.Enter Then Dim EditControl As DataGridViewTextBoxEditingControl = Me.ActiveControl Dim dg As DataGridView = EditControl.EditingControlDataGridView dg.EndEdit() ‘自己控制单元格的位置 dg.CurrentCell = dg.Item(4,
End If Else MyBase.ProcessCmdKey(aoMsg, aoKey) End If End Function
http://topic.csdn.net/t/20060104/22/4498631.html
Public Class Form1
Inherits System.Windows.Forms.Form
#Region ” Windows 窗体设计器生成的代码 ”
Public Sub New()
MyBase.New()
‘该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
‘在 InitializeComponent() 调用之后添加任何初始化
End Sub
‘窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
‘Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
‘注意: 以下过程是 Windows 窗体设计器所必需的
‘可以使用 Windows 窗体设计器修改此过程。
‘不要使用代码编辑器修改它。
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
Friend WithEvents Icon1 As System.Windows.Forms.NotifyIcon
Friend WithEvents ContextMenu1 As System.Windows.Forms.ContextMenu
Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.Label1 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.ListBox1 = New System.Windows.Forms.ListBox
Me.Icon1 = New System.Windows.Forms.NotifyIcon(Me.components)
Me.ContextMenu1 = New System.Windows.Forms.ContextMenu
Me.MenuItem1 = New System.Windows.Forms.MenuItem
Me.MenuItem2 = New System.Windows.Forms.MenuItem
Me.SuspendLayout()
‘
‘Label1
‘
Me.Label1.Location = New System.Drawing.Point(8,
Me.Label1.Name = “Label1″
Me.Label1.Size = New System.Drawing.Size(160, 16)
Me.Label1.TabIndex = 0
Me.Label1.Text = “请输入你要拨的电话号码:”
‘
‘TextBox1
‘
Me.TextBox1.Location = New System.Drawing.Point(8, 24)
Me.TextBox1.Name = “TextBox1″
Me.TextBox1.Size = New System.Drawing.Size(272, 21)
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = “”
‘
‘Button1
‘
Me.Button1.Location = New System.Drawing.Point(24, 56)
Me.Button1.Name = “Button1″
Me.Button1.TabIndex = 2
Me.Button1.Text = “拨号”
‘
‘Button2
‘
Me.Button2.Location = New System.Drawing.Point(192, 56)
Me.Button2.Name = “Button2″
Me.Button2.TabIndex = 3
Me.Button2.Text = “退出”
‘
‘ListBox1
‘
Me.ListBox1.ItemHeight = 12
Me.ListBox1.Location = New System.Drawing.Point(8, 88)
Me.ListBox1.Name = “ListBox1″
Me.ListBox1.Size = New System.Drawing.Size(272, 76)
Me.ListBox1.TabIndex = 4
‘
‘Icon1
‘
Me.Icon1.ContextMenu = Me.ContextMenu1
Me.Icon1.Icon = CType(resources.GetObject(“Icon1.Icon”), System.Drawing.Icon)
Me.Icon1.Text = “电话拨号”
Me.Icon1.Visible = True
‘
‘ContextMenu1
‘
Me.ContextMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1, Me.MenuItem2})
‘
‘MenuItem1
‘
Me.MenuItem1.Index = 0
Me.MenuItem1.Text = “退出”
‘
‘MenuItem2
‘
Me.MenuItem2.Index = 1
Me.MenuItem2.Text = “还原”
‘
‘Form1
‘
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(292, 174)
Me.Controls.Add(Me.ListBox1)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label1)
Me.Icon = CType(resources.GetObject(“$this.Icon”), System.Drawing.Icon)
Me.Name = “Form1″
Me.Text = “电话拨号”
Me.ResumeLayout(False)
End Sub
#End Region
Private Declare Function tapiRequestMakeCall Lib “tapi32.dll” (ByVal DestAddress As String, ByVal AppName As String, ByVal CalledParty As String, ByVal comment As String) As Integer
Const TAPIERR_CONNECTED As Short = 0
Const TAPIERR_DROPPED As Short = -1
Const TAPIERR_NOREQUESTRECIPIENT As Short = -2
Const TAPIERR_REQUESTQUEUEFULL As Short = -3
Const TAPIERR_INVALDESTADDRESS As Short = -4
Const TAPIERR_DESTBUSY As Short = -11
Const TAPIERR_UNKNOWNREQUESTID As Short = -15
Const TAPIERR_REQUESTFAILED As Short = -16
Private Sub EnableDial()
Button1.Enabled = Len(Trim(TextBox1.Text)) > 0
End Sub
Sub tapiStatus(ByRef strres As Integer)
Select Case strres
Case TAPIERR_CONNECTED
ListBox1.Items.Add(“信息:拨号已连接!”)
Case TAPIERR_INVALDESTADDRESS
ListBox1.Items.Add(“错误:错误的目的地址!”)
Case TAPIERR_NOREQUESTRECIPIENT
ListBox1.Items.Add(“错误:没有电话接口程序运行!”)
Case TAPIERR_REQUESTFAILED
ListBox1.Items.Add(“错误:拨号请求由于未知原因失败!”)
Case TAPIERR_DESTBUSY
ListBox1.Items.Add(“错误:对方电话正忙!”)
Case TAPIERR_UNKNOWNREQUESTID
ListBox1.Items.Add(“错误:没有这个电话号码!”)
Case TAPIERR_DROPPED
ListBox1.Items.Add(“错误:对方已挂断!”)
End Select
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strPhoneNum As String
Dim res As Integer
If Trim(TextBox1.Text) = “” Then
ListBox1.Items.Add(“错误:没有输入电话号码!”)
Exit Sub
Else
strPhoneNum = TextBox1.Text
End If
res = tapiRequestMakeCall(strPhoneNum, “Tapi Sample”, strPhoneNum, “”)
Call tapiStatus(res)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Close()
End Sub
Private Sub Form1_MinimumSizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.MinimumSizeChanged
Icon1.Visible = True
End Sub
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
Close()
End Sub
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
Me.Show()
End Sub
End Class