datagridview數(shù)據(jù)處理方法修改刪除添加下拉類表_第1頁
datagridview數(shù)據(jù)處理方法修改刪除添加下拉類表_第2頁
datagridview數(shù)據(jù)處理方法修改刪除添加下拉類表_第3頁
datagridview數(shù)據(jù)處理方法修改刪除添加下拉類表_第4頁
datagridview數(shù)據(jù)處理方法修改刪除添加下拉類表_第5頁
已閱讀5頁,還剩19頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、Datagridview的三種處理數(shù)據(jù)方法一、第一種方法常規(guī)方法,在窗口界面上放入一個(gè)datagridview,在放各個(gè)textbox,然后通過選取對應(yīng)的記錄,修改textbox的值,所有的操作都在一個(gè)界面上進(jìn)行,沒什么多說的,大部分方法都這么做、彈出窗口方式此方式,通過雙擊記錄,或者是利用按鈕操作,傾向于用按鈕方式,一次修改或添加、刪除一條記錄。利用窗口傳值方式,實(shí)現(xiàn)數(shù)據(jù)輸入、輸出,datagridview的顯示跟新。特點(diǎn):1。父子窗口之間的雙向傳值,很有參考意義2.父子窗體監(jiān)combox綁定數(shù)據(jù)表?xiàng)l件下,雙向傳值,很多資料接收的都不是很清晰,主要是利用了combox.findstring(

2、)這個(gè)方法,傳遞回index,利用index得到value,好繞啊,廢了很大勁。3 .datagridview修改、添加數(shù)據(jù)下,不用重新訪問數(shù)據(jù)庫,而是直接顯示修改的結(jié)果,這樣感覺反應(yīng)速度快,很有意義。具體如下修改界面System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;/表格自適應(yīng)寬度/DataCondatacon=newDataCon();/加載數(shù)據(jù)usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usi

3、ngSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;usingWDZ.CommonClass;namespaceWDZ三重若t”|hOK.舛戶得過造亂時(shí)*Irn-WainJDataOperatedataoperate=newDataOperate();stringstrSql=select*fromsql3DataSetds=dataoperate.getDs(strSql,sql3);dataGridViewl.DataSource=d

4、s.Tables0;/設(shè)置datagridview屬性dataGridView1.Columns0.ReadOnly=true;/列不可編寫dataGridView1.SelectionMode=DataGridViewSelectionMode.FullRowSelect;/選擇全行/dataGridView1.ReadOnly=true;/只讀dataGridView1.DefaultCellStyle.SelectionBackC010r=Color.YellowGreen;/選擇的行為顏色/最后一行的星號行不顯示,不允許用戶添加數(shù)據(jù)dataGridView1.AllowUserToAd

5、dRows=false;/*/加載下拉列表框BindSex();/綁定性別下拉列表框cmbTemp.Visible=false;/設(shè)置下拉列表框不可見/添加下拉列表框事件cmbTemp.SelectedIndexChanged+=newEventHandler(cmb_Temp_SelectedIndexChanged);/將下拉列表框加入到DataGridView控件中this.dataGridView1.Controls.Add(cmb_Temp);/*/datagridview中下拉類表框的綁定privateComboBox:mb_Temp=newComboBoX;/綁定性別下拉列表框/

6、privatevoidBindSex()DataTabledtSex=newDataTable();DataOperatedataoperate=newDataOperate();stringstrSql=select*fromuserclass;DataSetds=dataoperate.getDs(strSql,user_class);dtSex=ds.Tables0;cmbTemp.ValueMember=userclassid;/設(shè)置隱含的形式顯示數(shù)值,起對應(yīng)一定的名稱/cmbTemp.ValueMember=userclass;cmb_Temp.DisplayMember=user_

7、class;cmb_Temp.DataSource=dtSex;cmb_Temp.DropDownStyle=ComboBoxStyle.DropDownList;/只能選擇,不能寫入/cmbTemp.DropDownStyle=ComboBoxStyle.DropDown;/可以寫入/cmb_Temp.DropDownStyle=ComboBoxStyle.Simple;/當(dāng)用戶選擇下拉列表框時(shí)改變DataGridView單元格的內(nèi)容privatevoidcmbTempSelectedIndexChanged(objectsender,EventArgse)if(dataGridView1.

8、CurrentCell!=null)DataRowViewmyrowview=(DataRowVieWcmbTemp.SelectedItem;/dataGridView1.CurrentCell.Value=cmb_Temp.SelectedValue.ToString();dataGridView1.CurrentCell.Value=myrowview2.ToString();/選取的文本dataGridView1.CurrentCell.Tag=cmb_Temp.SelectedValue;/選取的編碼/MessageBox.Show(text:+cmbTemp.SelectedTex

9、t+-item:+cmbTemp.SelectedItem.ToString()+-value:+cmb_Temp.SelectedValue.ToString()+-index:+cmb_Temp.SelectedIndex.ToString();/DataRowViewmyrowview=(DataRowView)cmbTemp.SelectedItem;/MessageBox.Show(myrowview0.ToString()+-+myrowview1.ToString()+-+myrowview2.ToString();/獲得對應(yīng)的value和texttry(if(dataGridV

10、iewl.CurrentCell.ColumnIndex=3)(Rectanglerect=dataGridView1.GetCellDisplayRectangle(dataGridView1.CurrentCell.ColumnIndex,dataGridView1.CurrentCell.RowIndex,false);stringsexValue=dataGridView1.CurrentCell.Value.ToString();MessageBox.Show(sexValue);cmb_Temp.Text=sexValue;cmb_Temp.Left=rect.Left;cmb_T

11、emp.Top=rect.Top;cmbTemp.Width=rect.Width;cmb_Temp.Height=rect.Height;cmbTemp.Visible=true;)else(cmb_Temp.Visible=false;)catch()privatevoiddataGridView1CellDoubleClick(objectsender,DataGridViewCellEventArgse)=1if(e.ColumnIndex=0)DataGridViewdgv=senderasDataGridView;if(dgv.Rowse.RowIndex.Cells1.Value

12、!=null)stringid=dgv.Rowse.RowIndex.Cells0.Value.ToString();stringuser_id=dgv.Rowse.RowIndex.Cells1.Value.ToString();stringuserpassword=dgv.Rowse.RowIndex.Cells2.Value.ToString();stringuser_class=dgv.Rowse.RowIndex.Cells3.Value.ToString();stringuser_name=dgv.Rowse.RowIndex.Cells4.Value.ToString();str

13、inguser_sex=dgv.Rowse.RowIndex.Cells5.Value.ToString();stringoutUserid,outUserpassword,outUserclass,outUsername,outUsersex;DialogResultmyresult;this.ShowDialogForm(id,userid,userpassword,userclass,username,user_sex,outoutUserid,outoutUserpassword,outoutUserclass,outoutUsername,outoutUsersex,outmyres

14、ult);if(myresult=DialogResult.OK)dgv.Rowse.RowIndex.Cells1.Value=outUserid;dgv.Rowse.RowIndex.Cells2.Value=outUserpassword;dgv.Rowse.RowIndex.Cells3.Value=outUserclass;dgv.Rowse.RowIndex.Cells4.Value=outUsername;dgv.Rowse.RowIndex.Cells5.Value=outUsersex;privatevoidShowDialogForm(stringid,stringuser

15、id,stringuserpassword,stringuser_class,stringuser_name,stringuser_sex,outstringoutUserid,outstringoutUserpassword,outstringoutUserclass,outstringoutUsername,outstringoutUsersex,outDialogResultmyresult)dialog2frm=newdialog2();/讀取輸入?yún)?shù),顯示在子窗口中frm.ControlsIDTB.Text=id;frm.ControlsUSERIDTB.Text=userid;fr

16、m.ControlsUSER_PWD_TBText=user_password;frm.ControlsUSER_CLASS_TBText=user_class;/frm.USER_CLASS_CB.SelectedValue=2;frm.ControlsUSERNAMETBText=username;frm.ControlsUSER_SEX_T:Text=user_sex;frm.ShowDialog();/顯示子窗口/給輸出參數(shù)賦值默認(rèn)值outUserid=user_id;outUserpassword=userpassword;outUserclass=user_class;outUse

17、rname=username;outUsersex=user_sex;/判斷是否進(jìn)行修改數(shù)據(jù)myresult=frm.DialogResult;if(myresult=DialogResult.OK)/outUserid=frm.ControlsID_TB.Text;outUserid=frm.ControlsUSER_ID_TB.Text;outUserpassword=frm.ControlsUSER_PWD_TBText;outUserclass=frm.ControlsUSERCLASSCBText;outUsername=frm.ControlsUSERNAMETBText;outU

18、sersex=frm.ControlsUSER_SEX_TI|Text;MessageBoxShow(修改了數(shù)據(jù));frm.Dispose();MessageBoxShow(請先選擇一條記錄數(shù)據(jù)?。?return)采用彈出窗口方式,進(jìn)行數(shù)據(jù)修改DataGridViewdgv=dataGridViewl;if(dgv.Rowsselectrowindex.Cells1.Value!=null)(/輸入?yún)?shù)stringid=dgv.Rowsselectrowindex.Cells0.Value.ToString();stringuser_id=dgv.Rowsselectrowindex.Cell

19、s1.Value.ToString();stringuserpassword=dgv.Rowsselectrowindex.Cells2.Value.ToString();stringuser_class=dgv.Rowsselectrowindex.Cells3.Value.ToString();stringuser_name=dgv.Rowsselectrowindex.Cells4.Value.ToString();stringusersex=dgv.Rowsselectrowindex.Cells5.Value.ToString();stringoutUserid,outUserpas

20、sword,outUserclass,outUsername,outUsersex;/輸出參數(shù)DialogResultmyresult;/返回彈出窗口關(guān)閉狀態(tài)this.ShowDialogForm(id,userid,userpassword,userclass,username,user_sex,outoutUserid,outoutUserpassword,outoutUserclass,outoutUsername,outoutUsersex,outmyresult);/如 果 修 改 了 數(shù) 據(jù) , 把 當(dāng) 前datagridview內(nèi) 容 的 對 應(yīng) 值 進(jìn) 行 修 改if(myre

21、sult=DialogResult.OK)(dgv.Rowsselectrowindex.Cells1.Value=outUserid;dgv.Rowsselectrowindex.Cells2.Value=outUserpassword;dgv.Rowsselectrowindex.Cells3.Value=outUserclass;dgv.Rowsselectrowindex.Cells4.Value=outUsername;dgv.Rowsselectrowindex.Cells5.Value=outUsersex;)privatevoiddataGridView1CellClick(o

22、bjectsender,DataGridViewCellEventArgse)selectrowindex=e.RowIndex;)/添加記錄privatevoidbutton1_Click(objectsender,EventArgse)(/采用彈出窗口方式,進(jìn)行數(shù)據(jù)修改DataGridViewdgv=dataGridView1;/輸入?yún)?shù)stringid=-1stringuser_id=nullstringuser_password=null;stringuser_class=null;stringuser_name=null;stringuser_sex=nullstringoutUse

23、rid,outUserpassword,outUserclass,outUsername,outUsersex;/輸出參數(shù)DialogResultmyresult;/返回彈出窗口關(guān)閉狀態(tài)this.ShowDialogForm(id,user_id,user_password,user_class,user_name,user_sex,outoutUserid,outoutUserpassword,outoutUserclass,outoutUsername,outoutUsersex,outmyresult);/如果添加了數(shù)據(jù),把當(dāng)前datagridview內(nèi)容的對應(yīng)值進(jìn)行修改if(myres

24、ult=DialogResult.OK)(/添加行數(shù)據(jù)(DataTable)dataGridView1.DataSource).Rows.Add(1,outUserid,outUserpassword,outUserclass,outUsername,outUsersex);/dataGridView1是不能直接添加行的,只能在他的數(shù)據(jù)源里添,他會自動(dòng)綁定/獲取當(dāng)前選擇的行坐標(biāo)/)彈出窗口代碼usingSystem;stringmysql=deletefromuser_tb1whereID=+myid.ToString();DataOperatedataoperate=newDataOpera

25、te();dataoperate.getCom(mysql);MessageBoxShow(刪除數(shù)據(jù)成功);/加載數(shù)據(jù)mysql=select*fromsql3;DataSetds=dataoperate.getDs(mysql,sql3);dataGridViewl.DataSource=ds.Tables0;/*/獲取總頁碼SELECTCount(id)ASnumberlFROMuser_tb1;mysql=SELECTCount(id)ASnumberlFROMusertb1;DataSetds=dataoperate.getDs(mysql,usertb1);intindexsum=i

26、nt.Parse(ds.Tables0.Rows00.ToString();if(indexsum%pagesize=0)label5.Text=(indexsum/pagesize).ToString();else|label5.Text=(indexsum/pagesize+1).ToString();pagesum=int.Parse(label5.Text);/顯示當(dāng)前頁面)usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem

27、.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;usingWDZ.CommonClass;namespaceWDZpublicpartialclassdialog2:Formpublicdialog2()InitializeComponent();privatevoiddialog2Load(objectsender,EventArgse)stringmysql=select*fromuserclassorderbyid;bindcombox(USER_CLASS_CB,mysql,use

28、r_class);USERCLASSCB.SelectedIndex=USERCLASSCB.FindString(USERCLASS_TB.Text,-1);/*非常重要,利用string查找到對應(yīng)的index,然后就可以顯示了,或者取valueDataOperatedataoperate=newDataOperate();DataSetds=dataoperate.getDs(mysql,tbname);mydt=ds.Tables0;mycombox.ValueMember=mydt.Columns1.ColumnName;起對應(yīng)一定的名稱/cmbTemp.ValueMember=use

29、rclass;mycombox.DisplayMember=mydt.Columns2.ColumnName;mycombox.DataSource=mydt;ComboBoxStyle.DropDownList;/只能選擇,不能寫入/設(shè)置隱含的形式顯示數(shù)值,mycombox.DropDownStyle=/cmbTemp.DropDownStyle=ComboBoxStyle.DropDown;/可以寫入/cmb_Temp.DropDownStyle=ComboBoxStyle.Simple;privatevoidbutton1_Click(objectsender,EventArgse)/提

30、交數(shù)據(jù)庫操作,。修改數(shù)據(jù)DataOperatemydopt=newDataOperate();stringmysql=;修改數(shù)據(jù)if(ID_TB.Text!=-1)mysql=updateusertb1setuserid=+USERIDTB.Text+,userpassword=+USERPWDTB.Text+,user_class_id=+USER_CLASS_CB.SelectedValuemysql=insertintousertb1(user_id,user_password,user_class_id,user_name,user_sex)values(+USERPWDTB.Text

31、+USER_CLASS_CB.SelectedValue+USER_SEX_TB.Text+工/MessageBox.Show(mysql);mydopt.getCom(mysql);this.DialogResult=DialogResult.OK;privatevoidbutton2_Click(objectsender,EventArgse)1this.DialogResult=DialogResult.Cancel;直接在datagridview上修改、添加、刪除。不需要添加textbox。而且在view+,user_name=+USER_NAME_TB.Te)+,user_sex=+

32、USER_SEX_TB.Text+whereid=+ID_TB.Text;+USERIDTB.Text+IIIIII+USERNAMETB.Text+IIIIIIelseif(ID_TB.Text=-1)中有combox,下拉類表,可以一次修改多行數(shù)據(jù),很有意義。特點(diǎn):1.view中含有combox,利用了datarowview獲得選取的value,index,item都可以了2.一次可以修改多彳T數(shù)據(jù),利用dataapter的update的特性,比較麻煩3.可以直接在view中添加數(shù)據(jù),同樣利用update特性。問題這種方法,只能直接操作綁定的表,如果綁定的是視圖,現(xiàn)在還沒想好怎么解決。應(yīng)該

33、可以解決,需要記錄下所有修改的記錄的rowindex,然后利用sql語句分別進(jìn)行修改表,感覺比較麻煩,放棄了。代碼如下:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;usingWDZ.CommonClass;usingSystem.Data.OleDb;

34、namespaceWDZpublicpartialclassfrmMain:FormpublicfrmMain()IDuferJZIHrsevjBTTrariUEE.5fli12aaxn:SFL3同 c?OOKCCtt5SS7算cnrwrrtcFEB5B1的|JWX二LTwhLQannca:eaLTsIQillT221ZflOKOCL 二T-S-2253ainoQ:H立1fanxcr飛:唁樞由汨:牛哥當(dāng)朝止于J11*-甲 1 區(qū)式產(chǎn)iiL?:rInitializeComponent();)privatevoidfrmMain_Load(objectsender,EventArgse)(this

35、.dataGridView1.AutoSizeColumnsMode=System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;/表格自適應(yīng)寬度/DataCondatacon=newDataCon();DataOperatedataoperate=newDataOperate();stringstrSql=select*fromusertb1;DataSetds=dataoperate.getDs(strSql,user_tb1);dataGridViewl.DataSource=ds.Tables0;dataGridView1.Col

36、umns0.ReadOnly=true;/列不可編寫dataGridViewl.SelectionMode=DataGridViewSelectionMode.FullRowSelect;/選擇全行/dataGridViewl.ReadOnly=true;/只讀dataGridViewl.DefaultCellStyle.SelectionBackC010r=Color.YellowGreen;/選擇的行為顏色/最后一行的星號行不顯示,不允許用戶添加數(shù)據(jù)dataGridViewl.AllowUserToAddRows=false;button6.Enabled=false;button7.En

37、abled=false;/初始化索引數(shù)組for(inti=0;i20;i+)intindexi=255;/*/加載下拉列表框BindSex();/綁定性別下拉列表框cmbTemp.Visible=false;/設(shè)置下拉列表框不可見/添加下拉列表框事件cmbTemp.SelectedIndexChanged+=newEventHandler(cmb_Temp_SelectedIndexChanged);/將下拉列表框加入到DataGridView控件中this.dataGridView1.Controls.Add(cmb_Temp);privatevoidbutton1_Click(object

38、sender,EventArgse)(stringmsg=String.Format(第0行,第1歹1J,值:2,dataGridView1.CurrentCell.RowIndex,dataGridView1.CurrentCell.ColumnIndex,dataGridView1.CurrentCell.Value);label1.Text=選擇的單元格為:+msg;System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;/表格自適應(yīng)寬度/DataCondatacon=newDataCon();DataOperatedataop

39、erate=newDataOperate();pagesize=int.Parse(textBox1.Text);/每頁顯示的記錄數(shù)stringstrSql=selecttop+pagesize.ToString()+*fromusertb1DataSetds=dataoperate.getDs(strSql,user_tb1);dataGridView1.DataSource=ds.Tables0;dataGridView1.Columns0.ReadOnly=/獲取第1頁頁碼label2.Text=1;pagenumber=1;/獲取總頁碼SELECTCount(id)ASnumber1F

40、ROMusertb1;strSql=SELECTCount(id)ASnumber1FROMuser_tb1ds=dataoperate.getDs(strSql,usertb1);intindexsum=int.Parse(ds.Tables0.Rows00.ToString();if(indexsum%pagesize=0)label5.Text=(indexsum/pagesize).ToString();elselabel5.Text=(indexsum/pagesize+1).ToString();true;/列不可編寫this.dataGridView1.AutoSizeColum

41、nsMode=pagesum=int.Parse(label5.Text);/設(shè)置上一頁下一頁按鈕的可用性if(pagesum=1)button7.Enabled=falseelsebutton7.Enabled=true;button6.Enabled=true;intintindex=newint20;/假設(shè)一張表上默認(rèn)數(shù)據(jù)為intselectindex=0;OleDbConnectionconn;OleDbDataAdapteradapter;privateDataTabledbconn(stringstrSql)DataConmyconn=newDataCon();conn=mycon

42、n.getCon();this.adapter=newOleDbDataAdapter(strSql,conn);DataTabledtSelect=newDataTable();intrnt=this.adapter.Fill(dtSelect);returndtSelect;privateBooleandbUpdate()stringstrSql=select*fromusertb1;DataTabledtUpdate=newDataTable();dtUpdate=dbconn(strSql);dtUpdate.Rows.Clear();DataTabledtShow=newDataTa

43、ble();dtShow=(DataTable)this.dataGridViewl.DataSource;/dtUpdate.ImportRow(dtShow.Rowsintindex);/只能夠插入最后修改的一行數(shù)據(jù)。for(inti=0;i20;i+)if(intindexi!=255)dtUpdate.ImportRow(dtShow.Rowsintindexi);)二20個(gè)如果不進(jìn)行循環(huán)多行插入的話,try/SqlCommandBuilderCommandBuilder;OleDbCommandBuilderCommandBuilder;CommandBuilder=newOleDb

44、CommandBuilder(this.adapter);this.adapter.Update(dtUpdate);)catch(Exceptionex)MessageBoxShow(ex.Message.ToString();returnfalse;)dtUpdate.AcceptChanges();returntrue;)privatevoidbutton4Click(objectsender,EventArgse)if(dbUpdate()1MessageBoxShow(修改成功!);)for(inti=0;i(selectmax(id)from(selecttop+pageindex

45、.ToString()+idfromusertb1orderbyid);pageindex=(pagenumber-1)*pagesize;strSql=SELECTTOP+pagesize.ToString()+*FROMuser_tb1WHEREid(selectmax(id)from(selecttop+pageindex.ToString()+idfromusertb1orderbyid)elsestrSql=selecttop+pagesize.ToString()+*fromuser_tb1/MessageBox.Show(strSql);/調(diào)試使用DataSetds=dataop

46、erate.getDs(strSql,user_tb1);dataGridView1.DataSource=ds.Tables0;dataGridView1.Columns0.ReadOnly=true;/列不可編寫/顯示當(dāng)前的頁數(shù)if(pagenumber0)npageindex=(pagenumber-2)*pagesize;/已經(jīng)顯示的條目數(shù)strSql=SELECTTOP+pagesize.ToString()+*FROMuser_tb1WHEREid(selectmax(id)from(selecttop+pageindex.ToString()+idfromusertb1order

47、byid);)elsestrSql=selecttop+pagesize.ToString()+*fromuser_tb1DataSetds=dataoperate.getDs(strSql,dataGridViewl.DataSource=ds.Tables0;dataGridView1.Columns0.ReadOnly=/顯示當(dāng)前的頁數(shù)if(pagenumber!=1)pagenumber=pagenumber-1;elsepagenumber=1;label2.Text=pagenumber.ToString();|privatevoidtextBox1_TextChanged(obj

48、ectsender,EventArgse)1pagesize=int.Parse(textBox1.Text);privatevoidbutton5_Click(objectsender,EventArgse)/取消按鈕,其實(shí)就是從新讀本頁數(shù)據(jù)庫,在顯示一次DataOperatedataoperate=newDataOperate();intpageindex=0;/已經(jīng)顯示的條目數(shù)stringstrSql;if(pagenumber-1)0)Ipageindex=(pagenumber-1)*pagesize;/已經(jīng)顯示的條目數(shù)strSql=SELECTTOP+pagesize.ToStri

49、ng()+*FROMuser_tb1WHEREid(selectmax(id)from(selecttop+pageindex.ToString()+idfromusertb1orderbyid);elsestrSql=selecttop+pagesize.ToString()+user_tb1);true;/列不可編寫*fromusertb1DataSetds=dataoperate.getDs(strSql,user_tb1);dataGridViewl.DataSource=ds.Tables0;dataGridView1.Columns0.ReadOnly=true;/列不可編寫pri

50、vatevoidbutton8Click(objectsender,EventArgse)/顯不到最后一頁DataOperatedataoperate=newDataOperate();pagenumber=pagesum;button7_Click(sender,e);/添加行數(shù)據(jù)(DataTable)dataGridView1.DataSource).Rows.Add(1,000000);/就這一句就可以了,兄弟!也就是說dataGridView1是不能直接添加行的,只能在他的數(shù)據(jù)源里添,他會自動(dòng)綁定privatevoidbutton9Click(objectsender,EventArg

51、se)intmyid=int.Parse(dataGridView1.Rowsselectindex.Cells0.Value.ToString();stringmysql=deletefromuser_tb1whereID=+myid.ToString();DataOperatedataoperate=newDataOperate();dataoperate.getCom(mysql);MessageBoxShow(刪除數(shù)據(jù)成功);/獲取總頁碼SELECTCount(id)ASnumber1FROMusertb1;mysql=SELECTCount(id)ASnumber1FROMuser_tb1;DataSetds=dataoperate.getDs(mysql,usertb1);intindexsum=int.Parse(ds.Tables0.Rows00.ToString();if(indexsum%pagesize=0)label5.Text=(indexsum/page

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論