Custom Object Databinding Question

  • Thread starter Thread starter Frank Wisniewski
  • Start date Start date
F

Frank Wisniewski

I have the following persudo code:

//My Form Class
class Form1 {

//Local Variable for my custom object
private MyCustomObject1

//Constructor for Form Class
public Constructor{
MyCustomObject1 = new MyCustomObject1();
MyCustomObject1.MyProp = "Test";
textbox.databindings.add("text", this._MyCustomObject1, "MyProp1");
}

public ChangeCustomObject {
MyCustomObject1 = new MyCustomObject1();
MyCustomObject1.MyProp = "Change Test";
}

}

//Custom Class the contains one Property
class MyCustomObject {

property string MyProp1;

}

I databind a text boxes text property to my MyCustomObjects MyProp1 property
once in the constructor. This works fine, if I update the text box, the
value for MyProp1 is also updated. But if I change MyCustomObject1 to a new
MyCustomObject, the text box is not updated unless I call the
Databindings.Add again. Is this suppose to work this way? Do I have to
call Databindings.Add each time I set myCustomObject1 to a new
myCustomObject?

Thanks in advance,
 
Yes, it is supposed to work that way. You could make a container for your
custom object and make your 'changable' custom object just a property in
that container (and add your data binding to the container, which would
never change). But unless you do something like that you will have to
re-bind each time.

Richard

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
Frank Wisniewski said:
I have the following persudo code:

//My Form Class
class Form1 {

//Local Variable for my custom object
private MyCustomObject1

//Constructor for Form Class
public Constructor{
MyCustomObject1 = new MyCustomObject1();
MyCustomObject1.MyProp = "Test";
textbox.databindings.add("text", this._MyCustomObject1, "MyProp1");
}

public ChangeCustomObject {
MyCustomObject1 = new MyCustomObject1();
MyCustomObject1.MyProp = "Change Test";
}

}

//Custom Class the contains one Property
class MyCustomObject {

property string MyProp1;

}

I databind a text boxes text property to my MyCustomObjects MyProp1 property
once in the constructor. This works fine, if I update the text box, the
value for MyProp1 is also updated. But if I change MyCustomObject1 to a new
MyCustomObject, the text box is not updated unless I call the
Databindings.Add again. Is this suppose to work this way? Do I have to
call Databindings.Add each time I set myCustomObject1 to a new
myCustomObject?

Thanks in advance,


--
Frank Wisniewski MCSE 4.0, MCP+I, A+
f p w 2 3 @ h o t m a i l . c o m




----------------------------------------------------------

----------------------------------------------------------
http://www.usenet.com


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 
Thanks Richard, but let me take it a step deeper now,

Lets say my form1 class has a public property called myFormCustomObject
which returns the private variable MyCustomObject1. If I bind a textboxes
text property to a property of the mycustomobject property of the form like
so:

this.textbox.databindings.add("text", this, "myFormCustomObject");

should this work,

because I have it set this way in my code now and it does not work for me.
Am I binding the wrong way or something.
 
Sorry, I just reread my last post and I missed something, I meant the line
of code to read:

this.textbox.databindings.add("text", this.myFormCustomObject, "MyProp1");

--
Frank Wisniewski MCSE 4.0, MCP+I, A+
f p w 2 3 @ h o t m a i l . c o m
Frank Wisniewski said:
Thanks Richard, but let me take it a step deeper now,

Lets say my form1 class has a public property called myFormCustomObject
which returns the private variable MyCustomObject1. If I bind a textboxes
text property to a property of the mycustomobject property of the form like
so:

this.textbox.databindings.add("text", this, "myFormCustomObject");

should this work,

because I have it set this way in my code now and it does not work for me.
Am I binding the wrong way or something.

--
Frank Wisniewski MCSE 4.0, MCP+I, A+
f p w 2 3 @ h o t m a i l . c o m





----------------------------------------------------------

----------------------------------------------------------
http://www.usenet.com


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top