Hi all - I have a problem with implementing interfaces in a C# project.
I have a Windows form with the following interface in it:
public interface Trigger
{
void UpdateClient();
void UpdateHotel();
}
class UpdateParties: Trigger
{
static void Main()
{
UpdateParties iImp = new UpdateParties();
iImp.UpdateClient();
iImp.UpdateHotel();
}
public void UpdateClient ()
{
this.toolStripStatusLabelGuestID.Text = "Client ID: " + globals.CurrentGuestID;
this.tbGuest.Text = globals.PreFill;
}
public void UpdateHotel ()
{
this.toolStripStatusLabelHotelID.Text = "Hotel ID: " + globals.CurrentHotelID;
this.tbHotel.Text = globals.PreFill;
GetHotelData();
}
where GetHotelData() is used elsewhere by a button click event on the form itself.
Now I'm facing two problems when I try and compile this. The first is an error message along the lines of
'Myproject.frmDisplay.UpdateParties' does not contain a definition for 'toolStripStatusLabelGuestID' and no extension method 'toolStripStatusLabelGuestID' accepting a first argument of type 'Myproject.frmDisplay.UpdateParties' could be found (are you missing a using directive or an assembly reference?)
- this pops up every time I reference a control on the form itelf (toolStripStatusLabelHotelID is a label on the toolstrip bar, same thing happens for a textbox called tbGuest) and so I get four error messages of this kind.
The second error is
The name 'GetHotelData' does not exist in the current context when it comes to invoking
GetHotelData(). I don't want to duplicate GetHotelData() as it plays with data tables etc. on the main form and I can't shuffle those around.
How do I resolve these issues? I have other code in the form itself that invokes GetHotelData() and manipulates the controls just fine, and I don't want to start breaking things. All I need to do is invoke these methods from another form so that this form updates its display.