c# - change cell in datagridview to empty value -


i have method change cell in datagridview , works fine when rewrite text (string) .
want example rewrite email empty value , dont know how this.
i can rewrite email email (string string)

method change cell :

public void changecellemail(int col, string[] emails)     {           string sep = ";";         string text = "";          foreach (datagridviewcell cell in datagridview1.selectedcells)         {               (int = 0; < emails.length ;i++)             {                  if (emails[i].tostring().trim() != "")                 {                       text = text + emails[i] + sep ;                     datagridview1.rows[cell.rowindex].cells[col].value = text;                 }             }          }      } 

the calling code of method is

            string mail = txtbox1.text;             string mail1 = txtbox2.text;             string mail2 = txtbox3.text;             string mail3 = txtbox4.text;             string mail4 = txtbox5.text;              string[] mails = new string[] { mail, mail1, mail2, mail3, mail4 };               frm1.changecellemail(2, mails);             this.dispose(); 

thanks guys .

using following code can pass in 5 complete email address's of / "empty" , tempvar contain correct data.

public form1()     {         initializecomponent();          const string mail = "first";         const string mail1 = "second";         const string mail2 = "third";         const string mail3 = "";         const string mail4 = "fifth";          var mails = new string[] { mail, mail1, mail2, mail3, mail4 };          changecellemail(2, mails);     }       public void changecellemail(int col, string[] emails)     {         var sep = ";";         var text = "";         var tempvar = ""; //new temp variable (representing datagrid.value)          (int emaillist = 1; emaillist < 5; emaillist++)         {             (var = 0; < emails.length; i++)             {                  if (emails[i].trim() != "")                 {                     text = text + emails[i] + sep;                     tempvar = text;                 }                 else                 {                     tempvar = string.empty;                 }             }          }      } 

check tempvar on each loop , you'll see referring to.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -