Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create new row in dataset and move to it
Message
 
 
To
29/01/2010 01:04:28
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01446330
Message ID:
01446486
Views:
23
Hi Bonnie,

Still I am not seeing the grid moving the pointer to the new record. The only difference in my code (and maybe this is what make a difference) is that my BindingSource is defined in the InitalizedComponet() method of the Form.Designer.cs and this is done by designer. The code is:
this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components);
Also my bindings for grid and textboxes (done as you suggested) in a method of the form class (where I also get the typed dataset).

So the only difference I see between your code and mine is that you declared the BindingSource private.

I will keep trying different combinations of the code to see if I spot what makes the difference.

Thank you.

>Dmitry, what you've done should work. Be sure that you're using the same BindingSource for everything:
>
>
>private BindingSource MyBs = new BindingSource();
>
>// Set the BindingSource
>this.MyBs.DataSource = this.MyDataTable;
>
>// Set the bindings for grid and textbox
>this.MyGrid.DataSource = this.MyBs;
>this.MyTextBox.DataBindings.Add("Text", this.MyBs, "MyColumn");
>
>// Add a row
>this.MyDataTable.Rows.Add(this.MyDataTable.NewRow());
>this.MyBs.MoveLast();
>
>
>~~Bonnie
>
>PS - Viv, you were doing fine without me. <g>
>
>
>
>>>
>>>You need to create a row to be added:
>>>DataRow r = oMyDataSet.dtMyTable.NewRow()
>>> oMyDataSet.dtMyTable.Rows.Add(r);
>>
>>Thank you. Still I don't see the new record in the grid and in the textboxes (I suppose to see empty record and empty values in the textboxes). I am sure I am probably still missing something. What I have, after the code that creates and adds a new row - as you suggested, is call to MoveLast() in the bindingSource.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform