user control

H

Hrvoje Voda

I made a userControl for searching data in database.
When I click a button Search in that userControl I would like to see result
in another userControl grid.
But it seems that that event never occures. Why?

UserControl:

public partial class CtlReceptiSearch : UserControl

{

public CtlReceptiSearch(Db db, string table)

{

InitializeComponent();

this.db = db;

this.table = table;

}

string table = "";

public delegate void SearchResult(Object sender, EventArgs e);

public event SearchResult srcResult;

private void cmbSearch_SelectedIndexChanged(object sender, EventArgs e)

{

if (cmbSearch.Text.Length > 0)

{

if (cmbSearch.Text == "Po nazivu recepta")

receptiDatum.Enabled = false;

else

txtNaziv.Enabled = false;

}

txtNaziv.Focus();

}

void SrcResult ()

{

if (cmbSearch.Text.Length > 0)

{

switch (cmbSearch.Text)

{

case "Name":

db.ReceptiSearchNaziv(table, txtName.Text);

break;

case "Date:":

db.ReceptiSearchSastojci(table, Datum.Text);

break;

default:

db.ReceptiSearchNaziv(table, txtNaziv.Text);

break;

}

}

}

private void buttonSearch_Click(object sender, EventArgs e)

{

if (srcResult != null)

return;

else

SrcResult();

}

}



Another UserControl:



public CtlKol(Db db)

{

InitializeComponent();

this.db = db;

CtlReceptiSearch rSearch = new CtlReceptiSearch(db, "Kol");

rSearch.buttonSearch.Click += new EventHandler(srcResult);

}



void srcResult(object sender, EventArgs e)

{

grid.Refresh();

grid.Table = db.resultTable;

}
 
R

Radenko Zec

Hello Hrvoje,
pola je na hrvatskom a pola na engleskom,mislis da ce to neko skontati od
engleza?:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top