User Control has no impact on parent control carrencyManager

  • Thread starter Thread starter David K.
  • Start date Start date
D

David K.

My question concerns C# Windows Forms user controls.
I have created navigation user control. It gets the consumer
application parent control's (a Form) CurrencyManager to its bindable
property. In the user control, any change in the CurrencyManager
position is displayed OK.
The problem is that the position of the parent CurrencyManager stays
intact (doesn't change at all).
Here is the code of the consumer application:

private void Form1_Load(object sender, System.EventArgs e)
{
dataGrid1.DataSource = ds.Customers;

// Set the UserContol's properties
this.userControl11.ParentControl = this;
this.userControl11.ControlCurrencyManager = (CurrencyManager)
this.BindingContext[ds,"Customers"];
}

In methods, a reference parameter solves such problem, but I don't know
how to implement it with a user control.
Any help will be very much appreciated.


Thanks,
David
 
Hi,

Sorry to ask but if you want the parent to have the currencyManager as well
where are you calling it on your function? I can't see it.

Anything assigned to your usercontrol will remain within that boundary, in
your example you are assigning the currencymanager to your user control and
not to the parent at all.

Maybe I didn't understand what you mean...

Regards
Salva
 
Hi Salva,
The Form1_Load function is in the cunsumer application Windows Form. I
assign The Form's CurrencyManager to the the CurrencyManager property
of the user control.
I expect that any change that is made in the Position property of the
CurrencyManager in the user control, will be made in the
CurrencyManager.Position of the Form in the cunsumer application, as
well. Unfortunately, it stays intact.
If it is impossible, maybe there is a way for the user control to
return an object.

David
 
Hi,

The usercontrol is able to return whatever you want, if you want to retrieve
an object just use:

public class YourUserControl
{
private object WhateverObject;

public object GetObject
{
get { return WhateverObject;}
}
}

You can apply this to any object, including your currencymanager. Also you
can return it on a function, or by ref/out in a parameter.

Cheers
Salva


}
 
Back
Top