c# - How can I check if all the rows in DataGridView is not null? -


i had problem quite while.

what planned if of cell[0] has value, trigger event. if there null, it'll change value of textbox.

here's code:

private void button1_click(object sender, eventargs e) {     (int = 0; < datagridview1.rows.count; i++)     {         if (datagridview1.rows[i].cells[0].value.tostring() == null)         {             textbox.text = "null";             break;         }         else          {             messagebox.show("no null");         }     } 

but whats happening here example have 3 rows in datagridview, if first row not null lunch messagebox. want messagebox triggered when of row's cells not null.

try this:

bool anynull = false; (int = 0; i<datagridview1.rows.count; i++) {     if (datagridview1.rows[i].cells[0].value.tostring() == null)     {         textbox.text = "null";         anynull = true;         break;     } }  if (!anynull)     messagebox.show(""); 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -