Related trivia points (from the Small lottery system)

Source: Internet
Author: User

First, WinForm DataGridView knowledge Points

1. Custom DataGridView row and column headings

DataTable dt =selectdata ();d Gldresult.datasource=dt. DefaultView; #regionGenerate Data tables/// <summary>        ///Generate Data Tables/// </summary>        /// <returns></returns>        PrivateDataTable Selectdata () {List<string> Lsdat =Newlist<string>(); DataTable Dtdata=NewDataTable (); DTDATA.COLUMNS.ADD (NewDataColumn ("number of",typeof(string))); DTDATA.COLUMNS.ADD (NewDataColumn ("Lottery Results"));            DataRow Dr;  for(inti =1; I < -; i++) {Dr=Dtdata.newrow (); Lsdat=SData (i); StringBuilder SB=NewStringBuilder (); if(I >Ten)                {                    stringnum = i.ToString (). Substring (1,1); dr["number of"] ="Live Draw No."+ num +"Wheel"; }                Else{dr["number of"] ="Section"+ i +"Wheel"; }                foreach(stringNuminchLsdat) {sb. Append (Num+","); }                if(!string. IsNullOrEmpty (sb.) ToString ())) {dr["Lottery Results"] = sb. ToString (). Substring (0, SB. Length-1);            } dtData.Rows.Add (DR); }            returnDtdata; }         #endregion
View Code

2. Fill in the details of the DataGridView form

#regionFilter out data based on incoming I/// <summary>        ///filter out data based on incoming I/// </summary>        /// <param name= "i" ></param>        /// <returns></returns>        Privatelist<string> SData (inti) {List<string> Lsworkid =Newlist<string>(); DataSet DS=NewDataSet (); Try{Oledcon=Sqlhelper.oledcon ();                Oledcon.open (); stringSqlselect ="Select WorkID from ldresultlist where num="+i; Oledda=NewOleDbDataAdapter (Sqlselect, Oledcon);            Oledda.fill (DS); }            Catch(Exception ex) {Throw NewException (ex.            Message); }            finally{oledcon.dispose ();            Oledcon.close (); }            foreach(DataRow DrinchDs. tables[0]. Rows) {Lsworkid.add (dr[0].            ToString ()); }            returnLsworkid; }         #endregion
View Code

3. Get the value of the DataGridView Cheakboxcolumn control

Dgldresult.rows[i]. cells[0]. Editedformattedvalue.tostring ()
// using LINQ             expressions // var queryrows = from DataGridViewRow row in   dgldresult.rows             //                where (bool) row. cells["XZ"]. Value            //                select row;

Second, refresh the form

this. Showresult_load (sender, E);

Iii. Drawing of forms

 //private void Drawdt ()//{        //int padding = 25; //define the size of a small lattice//Graphics g = creategraphics (); //Pen pen = new Pen (Color.    Green); //The brush, the parameter inside is the color of the brush//    //Draw Horizontal lines//for (int i = 0; i < Panel1. height/padding; i++)//    {        //G.drawline (pen, 0, padding * I, panel1.        Width, padding * i); //    }        //    //draw a vertical line//for (int i = 0; i < Panel1. width/padding; i++)//    {        //g.drawline (pen, padding * I, 0, padding * I, panel1.        Height); //    }        //}

Related trivia points (from the Small lottery system)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.