Receive event in class from form in C#
Posted on 2008-11-08
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:
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