C#: Communication between main-class and winforms-class. Cannot pass over the data -


i got little question causes me problems, sure not difficult, me right is.

i got 2 classes, 1 main-class , class of winform.

 foreach (ea.element theelement in mypackage.elements)   {   foreach (ea.attribute theattribute in theelement.attributes)     {      attribute = theattribute.name.tostring();      value = theattribute.default.tostring();      addattributevalue(attribute, value);      }     } 

here values , try write them datagrid, via method:

private void addattributevalue(string attribute, string value)     {         int n = datagridview1.rows.add();         datagridview1.rows[n].cells[0].value = attribute;         datagridview1.rows[n].cells[1].value = value;     } 

but compiler tells me, addattributevalue not in current context , cannot call it. got values want, cannot pass them on form. know sounds trivial, can't it.

if did understood, code snippets provided in diferent classes.

in case method should public.

like that:

public void addattributevalue(string attribute, string value) {     int n = datagridview1.rows.add();     datagridview1.rows[n].cells[0].value = attribute;     datagridview1.rows[n].cells[1].value = value; } 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -