user control

H

Hrvoje Voda

I'm using this code to check click event on usercontrol.
But I get an error:


User Control:(GridFilter)
public delegate void FilterText(string filterText);

public event FilterText textFilter;



private void buttonTrazi_Click(object sender, EventArgs e)

{

if (textFilter != null)

textFilter(txtFilter.Text);

}

Main form:

private void Main_Load(object sender, EventArgs e)

{

GridFilter.textFilter += new Utils.GridFilter.FilterText(gridFilter);

}

protected void gridFilter(string filter)

{

string tree = treeKolekcija.SelectedNode.Text;


switch (tree)

{

case "Akcioni":

DataRow[] afrows = db.dataSetKolekcija.Akcioni.Select("Naziv LIKE '" +
filter + "%'" );

DataTable newtable = new DataTable();

int c = 0;

foreach (object o in afrows[0].ItemArray)

{

newtable.Columns.Add(new DataColumn(string.Format("col{0}", c++),
o.GetType()));

}

foreach (DataRow dr in afrows)

{

newtable.Rows.Add(dr.ItemArray);

}

gridData.Grid.DataSource = newtable;


break;

}

}
 
K

Kevin Spencer

You haven't assigned the Button Click event handler to the handler method
you created.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 
H

Hrvoje Voda

I don't understand.
I have an event textFilter that I check in button_click event.

Kevin Spencer said:
You haven't assigned the Button Click event handler to the handler method
you created.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

Hrvoje Voda said:
I'm using this code to check click event on usercontrol.
But I get an error:


User Control:(GridFilter)
public delegate void FilterText(string filterText);

public event FilterText textFilter;



private void buttonTrazi_Click(object sender, EventArgs e)

{

if (textFilter != null)

textFilter(txtFilter.Text);

}

Main form:

private void Main_Load(object sender, EventArgs e)

{

GridFilter.textFilter += new Utils.GridFilter.FilterText(gridFilter);

}

protected void gridFilter(string filter)

{

string tree = treeKolekcija.SelectedNode.Text;


switch (tree)

{

case "Akcioni":

DataRow[] afrows = db.dataSetKolekcija.Akcioni.Select("Naziv LIKE '" +
filter + "%'" );

DataTable newtable = new DataTable();

int c = 0;

foreach (object o in afrows[0].ItemArray)

{

newtable.Columns.Add(new DataColumn(string.Format("col{0}", c++),
o.GetType()));

}

foreach (DataRow dr in afrows)

{

newtable.Rows.Add(dr.ItemArray);

}

gridData.Grid.DataSource = newtable;


break;

}

}
 
K

Kevin Spencer

You created a Button click event Handler method, but you didn't assign it to
the Button's Click event. You need to do something like the following:

buttonTrazi.Click += new EventHandler(buttonTrazi_Click);

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

Hrvoje Voda said:
I don't understand.
I have an event textFilter that I check in button_click event.

Kevin Spencer said:
You haven't assigned the Button Click event handler to the handler method
you created.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

Hrvoje Voda said:
I'm using this code to check click event on usercontrol.
But I get an error:


User Control:(GridFilter)
public delegate void FilterText(string filterText);

public event FilterText textFilter;



private void buttonTrazi_Click(object sender, EventArgs e)

{

if (textFilter != null)

textFilter(txtFilter.Text);

}

Main form:

private void Main_Load(object sender, EventArgs e)

{

GridFilter.textFilter += new Utils.GridFilter.FilterText(gridFilter);

}

protected void gridFilter(string filter)

{

string tree = treeKolekcija.SelectedNode.Text;


switch (tree)

{

case "Akcioni":

DataRow[] afrows = db.dataSetKolekcija.Akcioni.Select("Naziv LIKE '" +
filter + "%'" );

DataTable newtable = new DataTable();

int c = 0;

foreach (object o in afrows[0].ItemArray)

{

newtable.Columns.Add(new DataColumn(string.Format("col{0}", c++),
o.GetType()));

}

foreach (DataRow dr in afrows)

{

newtable.Rows.Add(dr.ItemArray);

}

gridData.Grid.DataSource = newtable;


break;

}

}
 
H

Hrvoje

I get an error on main form.

error : An object reference is required for the nonstatic field, method, or
property 'Utils.GridFilter.textFilter'
 
P

Peter Duniho

I get an error on main form.

error : An object reference is required for the nonstatic field, method,
or property 'Utils.GridFilter.textFilter'

"On main form" is not very useful information. Where specifically does
your error happen? What causes it to happen?

Not that you should at this point really need our help. It seems to me
that the error is pretty self-explanatory. Somewhere you are using
"Utils.GridFilter.textFilter" and it requires an object reference even
though you are not providing one. You should be able to figure that one
out. If not, you really need to provide actual information that describes
the context of the error for us.

Pete
 
H

Hrvoje Voda

it worked fine on another control.
Now, I put it on a different control and it doesn't work.
 

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