469,631 Members | 1,798 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

user control

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;

}

}
Apr 18 '07 #1
7 2857
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" <hr*********@luatech.comwrote in message
news:f0**********@ss408.t-com.hr...
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;

}

}


Apr 18 '07 #2
I don't understand.
I have an event textFilter that I check in button_click event.

"Kevin Spencer" <un**********@nothinks.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
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" <hr*********@luatech.comwrote in message
news:f0**********@ss408.t-com.hr...
>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;

}

}



Apr 18 '07 #3
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" <hr*********@luatech.comwrote in message
news:f0**********@ss408.t-com.hr...
>I don't understand.
I have an event textFilter that I check in button_click event.

"Kevin Spencer" <un**********@nothinks.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>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" <hr*********@luatech.comwrote in message
news:f0**********@ss408.t-com.hr...
>>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;

}

}




Apr 18 '07 #4
On Wed, 18 Apr 2007 03:12:41 -0700, Hrvoje Voda <hr*********@luatech.com>
wrote:
I'm using this code to check click event on usercontrol.
But I get an error:
What error do you get? Where does the error happen?
Apr 18 '07 #5
I get an error on main form.

error : An object reference is required for the nonstatic field, method, or
property 'Utils.GridFilter.textFilter'
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Wed, 18 Apr 2007 03:12:41 -0700, Hrvoje Voda <hr*********@luatech.com>
wrote:
>I'm using this code to check click event on usercontrol.
But I get an error:

What error do you get? Where does the error happen?

Apr 18 '07 #6
On Wed, 18 Apr 2007 13:10:31 -0700, Hrvoje <hr**********@zg.htnet.hr>
wrote:
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
Apr 18 '07 #7
it worked fine on another control.
Now, I put it on a different control and it doesn't work.
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Wed, 18 Apr 2007 13:10:31 -0700, Hrvoje <hr**********@zg.htnet.hr>
wrote:
>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

Apr 19 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by martin | last post: by
4 posts views Thread by louise raisbeck | last post: by
2 posts views Thread by rn5a | last post: by
3 posts views Thread by Fred Chateau | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.