//private System.Windows.Forms.NotifyIcon notifyIcon1;
private NotifyIcon notifyIcon1;
public Form5()
{
InitializeComponent();
//指定使用的容器
notifyIcon1 = new NotifyIcon();
//this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
//建立NotifyIcon
this.notifyIcon1.Icon = new Icon(@"C:\Documents and Settings\0130\My Documents\Downloads\easter-egg-6.ico");
this.notifyIcon1.Text = "NotifyIcon Example";
this.notifyIcon1.MouseDoubleClick += new MouseEventHandler(notifyIcon1_MouseDoubleClick);
}
private void Form5_SizeChanged(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Hide();
this.notifyIcon1.Visible = true;
}
}
protected void notifyIcon1_MouseDoubleClick(object sender, EventArgs e)
{
this.Show();
notifyIcon1.Visible = false;
this.WindowState = FormWindowState.Normal;
}
2011年4月21日 星期四
ListView導出excel
引用 using Microsoft.Office.Interop.Excel;
加入參考
private void SaveAsExcel(ListView list, string text)
{
//text为些Excel的标题
Microsoft.Office.Interop.Excel.Application ss = new Microsoft.Office.Interop.Excel.Application();//开启Excel
ss.Application.Workbooks.Add(true);
ss.Visible = true;
ss.Cells[1, 4] = text;
for (int x = 1; x <= list.Columns.Count; x++)
{
ss.Rows.Cells[2, x] = list.Columns[x - 1].Text;
}
for (int i = 3; i <= list.Items.Count + 2; i++)
{
for (int j = 1; j <= list.Columns.Count; j++)
{
ss.Rows.Cells[i, j] = list.Items[i - 3].SubItems[j - 1].Text + ",";
}
}
}
//listview不得有空白
加入參考
private void SaveAsExcel(ListView list, string text)
{
//text为些Excel的标题
Microsoft.Office.Interop.Excel.Application ss = new Microsoft.Office.Interop.Excel.Application();//开启Excel
ss.Application.Workbooks.Add(true);
ss.Visible = true;
ss.Cells[1, 4] = text;
for (int x = 1; x <= list.Columns.Count; x++)
{
ss.Rows.Cells[2, x] = list.Columns[x - 1].Text;
}
for (int i = 3; i <= list.Items.Count + 2; i++)
{
for (int j = 1; j <= list.Columns.Count; j++)
{
ss.Rows.Cells[i, j] = list.Items[i - 3].SubItems[j - 1].Text + ",";
}
}
}
//listview不得有空白
2011年4月20日 星期三
ListView資料分組
private void btnListView_Click(object sender, EventArgs e)
{
listView2.Groups.Clear();
listView2.Items.Clear();
listView2.View = View.Details;
ColumnHeader columnHeader0 = new ColumnHeader();
columnHeader0.Text = "Title";
columnHeader0.Width = 200;
ColumnHeader columnHeader1 = new ColumnHeader();
columnHeader1.Text = "Author";
columnHeader1.Width = 200;
ColumnHeader columnHeader2 = new ColumnHeader();
columnHeader2.Text = "Year";
columnHeader2.Width = 100;
{
listView2.Groups.Clear();
listView2.Items.Clear();
listView2.View = View.Details;
ColumnHeader columnHeader0 = new ColumnHeader();
columnHeader0.Text = "Title";
columnHeader0.Width = 200;
ColumnHeader columnHeader1 = new ColumnHeader();
columnHeader1.Text = "Author";
columnHeader1.Width = 200;
ColumnHeader columnHeader2 = new ColumnHeader();
columnHeader2.Text = "Year";
columnHeader2.Width = 100;
2011年4月8日 星期五
2011年4月7日 星期四
Come Together
Come Together
Here come old flattop he come grooving up slowly
He got joo-joo eyeball he one holy roller
He got hair down to his knee
Got to be a joker he just do what he please
He wear no shoeshine he got toe-jam football
He got monkey finger he shoot coca-cola
He say "I know you, you know me"
One thing I can tell you is you got to be free
Come together right now over me
He bag production he got walrus gumboot
He got Ono sideboard he one spinal cracker
He got feet down below his knee
Hold you in his armchair you can feel his disease
Come together right now over me
He roller-coaster he got early warning
He got muddy water he one mojo filter
He say "One and one and one is three"
Got to be good-looking 'cause he's so hard to see
Come together right now over me
Here come old flattop he come grooving up slowly
He got joo-joo eyeball he one holy roller
He got hair down to his knee
Got to be a joker he just do what he please
He wear no shoeshine he got toe-jam football
He got monkey finger he shoot coca-cola
He say "I know you, you know me"
One thing I can tell you is you got to be free
Come together right now over me
He bag production he got walrus gumboot
He got Ono sideboard he one spinal cracker
He got feet down below his knee
Hold you in his armchair you can feel his disease
Come together right now over me
He roller-coaster he got early warning
He got muddy water he one mojo filter
He say "One and one and one is three"
Got to be good-looking 'cause he's so hard to see
Come together right now over me
2011年4月6日 星期三
2011年4月1日 星期五
ListBox資料繫結
private void LoadListBox()
{
this.listBox1.DataSource = null;
this.listBox1.Items.Clear();
connString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
@"Data source= D:\VS2005\練習" +
@"\TestDB.mdb";
selectCmd = "SELECT * from dep";
//1.建立連線
using (OleDbConnection cn = new OleDbConnection(connString))
{
//2.開啟連線
cn.Open();
//3.建立OleDbCommand物件
using (OleDbCommand cmd = new OleDbCommand(selectCmd, cn))
{
//4.建立OleDbDataReader物件
using (OleDbDataReader dr = cmd.ExecuteReader())
{
//5.建立DataTable
DataTable dt = new DataTable();
//6.載入OleDbDataReader
dt.Load(dr);
//7.設定DataSource
listBox1.DataSource = dt;
//8.顯示成員
listBox1.DisplayMember = "DepNo";
}
}
}
資料來源~http://www.dotblogs.com.tw/yc421206/archive/2009/07/12/9356.aspx
{
this.listBox1.DataSource = null;
this.listBox1.Items.Clear();
connString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
@"Data source= D:\VS2005\練習" +
@"\TestDB.mdb";
selectCmd = "SELECT * from dep";
//1.建立連線
using (OleDbConnection cn = new OleDbConnection(connString))
{
//2.開啟連線
cn.Open();
//3.建立OleDbCommand物件
using (OleDbCommand cmd = new OleDbCommand(selectCmd, cn))
{
//4.建立OleDbDataReader物件
using (OleDbDataReader dr = cmd.ExecuteReader())
{
//5.建立DataTable
DataTable dt = new DataTable();
//6.載入OleDbDataReader
dt.Load(dr);
//7.設定DataSource
listBox1.DataSource = dt;
//8.顯示成員
listBox1.DisplayMember = "DepNo";
}
}
}
資料來源~http://www.dotblogs.com.tw/yc421206/archive/2009/07/12/9356.aspx
Insert, Update From SQL
//Update
static void cmdUpdate(string strPhone2, string strEmail2, string strRegion2, string strId2)
{
try
{
string connString = null;
connString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
@"Data source= D:\VS2005\練習" +
@"\TestDB.mdb";
using (OleDbConnection conn =
new OleDbConnection(connString))
{
conn.Open();
using (OleDbCommand cmd =
new OleDbCommand("UPDATE Infor SET Phone=@Phone, Email=@Email, Region=@Region" +
" WHERE Id=@Id", conn))
{
cmd.Parameters.AddWithValue("@Phone", strPhone2);
cmd.Parameters.AddWithValue("@Email", strEmail2);
cmd.Parameters.AddWithValue("@Region", strRegion2);
cmd.Parameters.AddWithValue("@Id", strId2);
int rows = cmd.ExecuteNonQuery();
//rows number of record got updated
cmd.Dispose();
}
}
}
catch (Exception ex)
{
//Log exception
//Display Error message
MessageBox.Show(ex.Message, "例外訊息");
}
}
static void cmdUpdate(string strPhone2, string strEmail2, string strRegion2, string strId2)
{
try
{
string connString = null;
connString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
@"Data source= D:\VS2005\練習" +
@"\TestDB.mdb";
using (OleDbConnection conn =
new OleDbConnection(connString))
{
conn.Open();
using (OleDbCommand cmd =
new OleDbCommand("UPDATE Infor SET Phone=@Phone, Email=@Email, Region=@Region" +
" WHERE Id=@Id", conn))
{
cmd.Parameters.AddWithValue("@Phone", strPhone2);
cmd.Parameters.AddWithValue("@Email", strEmail2);
cmd.Parameters.AddWithValue("@Region", strRegion2);
cmd.Parameters.AddWithValue("@Id", strId2);
int rows = cmd.ExecuteNonQuery();
//rows number of record got updated
cmd.Dispose();
}
}
}
catch (Exception ex)
{
//Log exception
//Display Error message
MessageBox.Show(ex.Message, "例外訊息");
}
}
訂閱:
文章 (Atom)