剪貼資料到剪貼簿上
private void setdatagridviewtoclipboard
將剪貼版上的資料儲存到datagridview上,不能從中間貼上
private void setclipboardtodatagridview()
int insertrowindex = datagridview2.currentcell.rowindex;
// 獲取剪下板的內容,並按行分割
string pastetext = clipboard.gettext();
if(string.isnullorempty(pastetext))
pastetext = pastetext.replace(" ", " ");
pastetext = pastetext.replace(' ', ' ');
pastetext.trimend(new char );
string lines = pastetext.split(new string ,stringsplitoptions.none);
bool isheader = false;
for (int r = 0; r < lines.length; r++)
foreach (string line in lines)
// 按 tab 分割資料
string vals = line.split(new char );
datagridviewrow row = datagridview2.rows[insertrowindex];
int insertcolumnsindex = datagridview2.currentcell.columnindex;
for (int i = 0; i < vals.length; i++)
// datagridview的行索引+1}}
datagridview資料繫結
sqlconnection conn new sqlconnection conn.connectionstring server local uid sa pwd sa database databasename sqlcommand cmd new sqlcommand cmd.commandt...
DataGridView查詢資料
機房收費中查詢記錄,肯定會用到datagridview,下面是我實現的乙個小功能 查詢學生上機記錄。一 時序圖 二 u層public class frmonlinequery private sub btnquery click sender as object,e as eventargs han...
資料匯入DataGridview
資料匯入datagridview,從資料庫傳來的table,不是泛型,table轉泛型沒有成功。然後我就放棄了,用傳來的table的資訊賦值 首先判斷幾行資料,要先個 空間,好比乙個房子要存貨,先要有空間,不是等貨物來了再創造空間。datagridview.rows.add table.rows.c...