Link to home
Start Free TrialLog in
Avatar of dvplayltd
dvplayltdFlag for Bulgaria

asked on

Receive event in class from form in C#

Hi experts!

I created WinForm application with C# 2008. I have one WinForm on which I have control (FarPoint Grid) and one class. Here I have two question:

1.      How to refer control from form to class, so when I change some property of control in class  to see this changed in Windows Form. Control is from type Spread.

2.      I need events like Leave, TextChanged for this control to be received in class automatically. Of course I can received this event in form and then to call function in class, but I will have many, many forms which will used this class and want to avoid to write code for this event in form which will actually do in class.



Here some code:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using FarPoint.Win.Spread;


namespace AC
{
    public class DataSpread
    {

        public Form frm;
        public Panel pa;
        public FpSpread grd;

        public Boolean mbFormView;
        public Boolean mbGridView;

        public int lCurrentRow;

        public void Init(FpSpread grdInit,  Panel fraTab,Form frmQSearch,string sDataObjectName,string sTable,string sPrimaryKey,string sreqFields, bool bFormView, Label lblRecordCount)
        {
       
            grd = grdInit; // Will this work for question 1

        }


    }
}
Avatar of Anurag Thakur
Anurag Thakur
Flag of India image

delegates and events are the way to go forward here
have a look at the following link here https://www.experts-exchange.com/questions/23736959/Communication-between-UserControls-and-Winforms.html
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dvplayltd

ASKER

It work! It work ! Thank you very much ! P.S: I'm from 8 years professional programmer, but new to C# and such help are very needed to me.