Argh, no BindableAttribute?

  • Thread starter Thread starter Peter Morris [Droopy eyes software]
  • Start date Start date
P

Peter Morris [Droopy eyes software]

Hi again!

System.ComponentModel.BindableAttribute seems to be missing in the CF, is
this correct?

How am I supposed to databind a TextBox.Text to MyObject.Property? Do I
have to update the object manually from the GUI?

Thanks

Pete
 
Just to clarify, when I do this

LoginTextBox.DataBindings.Add("Text", validateUserTask, "Login");

I get a NullReferenceException when my form tries to appear. Without the
databinding I do not get the exception.

Pete
 
Checkout the 'DataBindings' property. Your 'bindableattribute' is not
'missing', its just not part of the CF. You should take some time to
research the CF and what it is all about.

Chris
 
Hi Chris

I assumed I needed to explicitly include BindableAttribute on my property,
because the binding was causing an NullReferenceException.
Checkout the 'DataBindings' property.

My code uses the DataBindings property. This property is not visible in the
object inspector, so I added databindings manually (as per my second
posting).

Thanks

Pete
 
Hi Chris

A factory creates a UI control for me, like so....

if (currentTask is Eden.UITask.IUITask)
{
CurrentControl = (Control)
Eden.UITask.UITaskFactory.Instance.CreateTaskUI((Eden.UITask.IUITask)
currentTask);
CurrentControl.Location = new System.Drawing.Point(0, 0);
CurrentControl.Size = new System.Drawing.Size(this.ClientRectangle.Right,
NavigationPanel.Location.Y - 1);
this.Controls.Add(CurrentControl);
}

That all works just fine, the control is created and then inserted into my
form.

Next I check to see if the created control has an Initialize requirement,
like so......

initializeGui = CurrentControl as
Eden.HandheldVendor.TaskFlow.UI.IInitializeGui;
if (initializeGui != null)
initializeGui.InitializeGui();

In my InitializeGui() all I do is this....

LoginTextBox.DataBindings.Add("Text", ValidateUser, "Login");
PasswordTextBox.DataBindings.Add("Text", ValidateUser, "Password");

If I comment out those two lines, everything works just fine (without
binding), but as soon as I add those two lines I get a
NullReferenceException, which doesn't really tell me much at all :-)

The Login/Password properties are declared like so....

public string Login
{
get
{
return login;
}
set
{
login = value;
}
}

public string Password
{
get
{
return password;
}
set
{
password = value;
}
}


I only added the InitializeGui() call incase the databindings required the
control to be connected to a form before they would work, so I add the
databindings after the control has been inserted into the form.Controls

This is really confusing me, any help would be greatly appreciated!

Thanks

Pete
 
*Sigh*

Here it is....

Login and Password had no initial values, so they were both null. I can't
believe all of this grief was due to "null" instead of "".

I really appreciate you spending time on this, thanks very much!

Pete
 
Back
Top