views:

20

answers:

1

This is what I have..

Dim frmSettings As New frmOptions
frmSettings.ShowDialog(Me)

frmSettings is a settings form that you can choose the color for background of form1(Me). But I cannot access the form1 properties to change the backcolor.

+2  A: 

You could, however, provide a callback in the current form that the settings form could call when the property is changed that would do it for you. Sorry for the C#; too early in the AM for me to write VB. You'd probably need to have an interface that defines the set of methods used to change the properties and pass the Form as the interface so that the caller has access to the methods.

 public interface IChangeableProperties
 {
      void ChangeBackgroundColor( Color newColor );
      ...
 }

 public class MyForm : Form, IChangeableProperties
 {

     ...

     public void ChangeBackgroundColor( Color newColor )
     {
        ...
     }
 }

Then in your in the settings form

 private IChangeableProperties callingForm;

 public void ShowDialog( IChangeableProperties caller )
 {
      callingForm = caller;
      ...
 }

and in your event handler

 callingForm.ChangeBackgroundColor( selectedColor );
tvanfosson