Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
class class1
{
public void RefreshParameter()
        {
            gcUnitPRMS.ProcessGridKey += new KeyEventHandler(gcUnitPRMS_ProcessGridKey);

           // gcUnitPRMS.ProcessGridKey += new KeyEventHandler(gcUnitPRMS_ProcessGridKey);
        }

        public void gcUnitPRMS_ProcessGridKey(object sender, KeyEventArgs e)
        {
            GridControl grid = (GridControl)sender;
            GridView view = (GridView)grid.FocusedView;

            if (view.Name != "gvUnitPRMs")
                return;

            DataRowView master = (DataRowView)view.SourceRow;
            if (Convert.ToString(master["TypeCategory"]) == Categories.sUnitParameters)
                return;

            if (e.KeyCode == Keys.Enter)
            {
                if (!view.IsEditing)
                {

                    if (view.UpdateCurrentRow())
                    {

                        AddNewPRMRow(view);
                    }
                }
            }
            else if (e.KeyCode == Keys.Delete)
            {
                if (!view.IsEditing)
                {
                    DialogResult res = XtraMessageBox.Show("Are You Sure To Delete", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (res == DialogResult.Yes)
                    {

                        DeletePRMRow(view);
                    }
                }
            }
            AddNewPRMRow(view);
            int rhandle = view.FocusedRowHandle;
            GridColumn gcol = view.Columns["unit_param_desc"];
            view.SetFocusedRowCellValue(gcol, description1);
           
        }
}
class class2
{
class1 cs=new class1();
private void treeList1_AfterFocusNode(object sender, NodeEventArgs e)
    {
        TreeList tr1 = sender as TreeList;
        if (e.Node.ParentNode != null)
        {
            parameter.description = e.Node.GetValue("OPCName").ToString();
            if (e.Node.ParentNode.ParentNode != null)
            {
 cs.servername1 = e.Node.ParentNode.ParentNode.GetValue("OPCName").ToString();
    cs.host1 = e.Node.ParentNode.ParentNode.GetValue("OPCIPAddress").ToString();
                cs.RefreshParameter();
            }

        }      

    }

}

I have invoked the class1 function in another class in this function invoke the event of the grid but when i have call this it will not invoked the event.
why this happens.
thanks in advance.


[edit]Code block added, "Ignore HTML..." option disabled - OriginalGriff[/edit]
Posted
Updated 4-Jun-11 3:05am
v2
Comments
Sergey Alexandrovich Kryukov 4-Jun-11 21:56pm    
What is "invoking event __to__"? Can you explain on a short code sample?
--SA

1 solution

To my understanding, you mean to call the RefreshParameter method from class2 by instantiating,

There is no magic, if treeList1_AfterFocusNode event is fired and if a breakpoint at the line ' cs.RefreshParameter();' is hit your method will be invoked, ensure if the conditions in the previous lines are satisfied.

One more thing, you just have hooked an event in the RefreshParameter, this does not necessarily call the gcUnitPRMS_ProcessGridKey event, if you expect this to happen,! you may have to take a look at event handling.

Hope this helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900