Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd listview items from other form (using objects)
    primarykey
    data
    text
    <p>I want to get some data to fill a listview control, but this data it's determined in other form. This is what I code in form1 (Nuevo_Credito):</p> <pre><code>private void combo_cliente_SelectionChangeCommitted(object sender, EventArgs e) { Credito_Grupo ventana = new Credito_Grupo(combo_cliente.SelectedItem); ventana.ShowDialog(); } public void AgregaIntegrantes(string id, string nombre, string monto) { ListViewItem elem = new ListViewItem(id); elem.SubItems.Add(nombre); elem.SubItems.Add(monto); listView_integrantes.Items.Add(elem); } </code></pre> <p>I'm invoking form2 (Credito_grupo) as show dialog window, then I want to retrieve some values and pass them to Form1 using the public method "AgregaIntegrantes". So in form2 I did the following:</p> <pre><code>public Credito_Grupo(dynamic item) { this.id = item.IDCliente; this.nombre = item.NomComp; InitializeComponent(); } private void Credito_Grupo_Load(object sender, EventArgs e) { text_nombre.Text = this.nombre; } private void button_AgregaCliente_Click(object sender, EventArgs e) { Nuevo_Credito obj = new Nuevo_Credito(); obj.AgregaIntegrantes(id.ToString(), nombre, text_monto.Text); this.Close(); } </code></pre> <p>When the event button_AgregaCliente_click is triggered I need to add the data to listview in form1 using the method described above, but none data is added. I found a solution using delegates here <a href="https://stackoverflow.com/questions/3077677/add-to-listview-from-another-form">3077677</a>, is there an approach using objects?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload