Dataset acting strangely

G

Guest

Here is the situation, I extended the textbox windows control so that it has
an additional custom string property. I have a typed dataset and my extended
textbox's new property is bound to one of the columns of one of the tables in
this dataset.
Let's say I have a record in the table and the row state of the record is
"UnChanged". If I do BindingContext(myDataset,myTable).EndCurrentEdit then
some how the row state of the record changes to Modified. I tried to look at
the diffgram but It doesn't show what's changed. Let me know if this is a
bug?
 
K

Kevin Yu [MSFT]

Hi

We have reviewed this issue and are currently researching on it. We will
update you ASAP. Thanks for your patience!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
G

Guest

Thanks for the reply,
I think I wasn't clear on my initial posting. I have bound a field to
textboxes tag property. The problem occured and then I created a property as
the following
Public Property MyText() As String
Get
Return strMyText
End Get
Set(ByVal Value As String)
strMyText = Value
End Set
End Property
This causes the same behavior also.

My other question is why don't we use BindingContext ? I usually do it for a
dataset. If I want to endcurrentedit a table in the dataset regardless of
what it's fields are bound to, I use BindingContext.Item(datasetname,
TableName).EndCurrentEdit() Is this wrong? Is there a doc you can refer me to?
 
J

Jeffrey Tan[MSFT]

Hi Mach,

Thanks for your feedback!

I did not see any different about binding to Text property or your MyText
property, unless you did some customized work with your "MyText" property.
If so, I suggest you make a simplest sample project to help us to reproduce
out this issue, then we can understand your problem and help you better.

For the second question, because we are doing simple databinding here not a
complex databinding, we should use DataBindings property to get the Binding
object, then manipulate it, BindingContext should be used for complex
databinding such as DataGrid etc..

Anyway, I will wait for your further feedback. Thanks
=======================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Mach,

Thanks for your feedback!!

Yes, I have received your sample project. I have done research in this
project, it seems that this problem only occurs when we used the added new
prooperty of the inherited textbox class.

I will spend more time in this issue, and will reply to you ASAP. Thanks
for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Mach,

Sorry for letting you wait for so long.

I have done some research on this issue. The reason for this is that
Windows Forms EndCurrentEdit() method uses Reflection and looks for a
(property name)Changed event. If it finds this event, it listens for the
event to be raised in order to determine whether the field has changed. If
there is no event, then it has to assume always that the field value has
changed. If you look at the TextBox, you'll see a TextChanged event, which
explains why the Text property behaves differently than your custom
property. If you bind to a different property, such as AllowDrop, which
doesn't have a "Changed" event, then you'll see exactly the same behavior
as your property. Sample code lists below:

DataTable dt=null;
private void Form1_Load(object sender, System.EventArgs e)
{
dt=new DataTable();
dt.Columns.Add(new DataColumn ("field1", typeof(bool)));
dt.Columns.Add(new DataColumn ("field2", typeof(string)));

DataRow dr=dt.NewRow();
dr[0]=false;
dr[1]="test2";
dt.Rows.Add(dr);

dt.AcceptChanges();
this.textBox1.DataBindings.Add(new Binding("AllowDrop", dt, "field1"));
}

private void button1_Click(object sender, System.EventArgs e)
{

this.textBox1.DataBindings["AllowDrop"].BindingManagerBase.EndCurrentEdit();
int x=1;
}
You will see that "AllowDrop" property behaves the same as the extended
custom property.

Hope this makes sense to you.
===================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Mach,

Does my reply make sense to you? Do you still need help on this issue?
Please feel free to tell me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

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

Top