PC Review


Reply
Thread Tools Rate Thread

DataGrid's CurrentRowIndex doesn't show new row's index.

 
 
Thomas Berg
Guest
Posts: n/a
 
      9th Feb 2004
I've got a strongly typed dataset with three tables. Call them parent,
child, and grandchild. There are relationships between parent and child,
and between child and grandchild, using fields parentId and childId
respectively. parentId and childId are autoincrement, with seed = 0 and
step = -1.

On a form I've got a DataGrid (with the most important fields) and some
textboxes (with more details) at each level. That is:

dgParent.DataSource = ds
dgParent.DataMember = Parent
dgChild.DataSource = ds
dgChild.DataMember = Parent.Parent_Child
dgGrandchild.DataSource = ds
dgGrandchild.DataMember = Parent.Parent_Child.Child_Grandchild

txtParentDetail.DataBindings.Add(New Binding("Text", ds, _
"Parent.ParentDetail"))
txtChildDetail.DataBindings.Add(New Binding("Text", ds, _
"Parent.Parent_Child.ChildDetail"))
txtGrandchildDetail.DataBindings.Add(New Binding("Text", ds, _
"Parent.Parent_Child.Child_Grandchild.GrandchildDetail"))

Viewing data from the database, everything is cool. I can change existing
data and update it fine. I can create new grandchildren. The problem
arises when I click in the last (empty) row of the Child DataGrid, wanting
to create a new Child of the current parent. I enter some data, tab to the
next field, and the data I entered vanishes.

Furthermore, the Child-level textboxes continue to display the data of the
last Child record I was looking at (before I clicked into the last row of
the Child DataSet). I expected them become blank, showing that data has not
yet been entered for the new Child row.

Thinking perhaps the Child DataGrid and Child textboxes had somehow got
different CurrencyManagers. I took a look at this:
BindingContext(dgChild.DataSource, dgChild.DataMember) Is _
txtChildDetail.DataBindings("Text").BindingManagerBase.
But it was true, which I think is as it should be.

Then I put some code into the dgChild's CurrentCellChanged event, to display
the DataGrid's current row and the CurrencyManager's position in the status
bar.
MyStatBarPanel.Text = "DG: " & dgTktGrp.CurrentRowIndex.ToString & _
" CM: " & BindingContext(dgTktGrp.DataSource, _
dgTktGrp.DataMember).Position.ToString
What I found here was that the DataGrid's CurrentRowIndex and the
CurrencyManager's Position were always the same as each other, which is
good. BUT, neither of them changed when I clicked into the last (empty) row
of the DataGrid. Which doesn't seem right, does it?

If anyone can explain either (a) what I might be doing wrong to cause this
oddness or (b) why this behavior is perfectly natural and what is the proper
way to add new records at the Child level, I will be very grateful.

Thomas Berg

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
out of synch dataset and datagrid using CurrentRowIndex C# =?Utf-8?B?Um9icw==?= Microsoft Dot NET Framework Forms 0 2nd Jun 2006 02:35 AM
dataGrid CurrentRowIndex problem. Lagur Microsoft C# .NET 1 19th Apr 2005 05:19 PM
how to use CurrentRowIndex for datagrid control ? Sam Microsoft VB .NET 3 29th Mar 2005 09:58 PM
datagrid select vs currentRowIndex Deanna Delapasse Microsoft Dot NET Framework Forms 1 21st Sep 2004 04:52 AM
CurrentRowIndex in a datagrid and it not changing.... sometimes? =?Utf-8?B?ZmRp?= Microsoft Dot NET Framework Forms 0 2nd Apr 2004 02:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:43 AM.