<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Adding Items to a Child Grid</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : Adding Items to a Child Grid</description>
  <pubDate>Fri, 12 Jun 2026 10:01:21 -700</pubDate>
  <lastBuildDate>Wed, 06 Jun 2007 15:10:55 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=59</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Adding Items to a Child Grid : Answer: Naturally, the answer...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=59&amp;PID=131#131</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=21" rel="nofollow">IdeaBlade</a><br /><strong>Subject:</strong> 59<br /><strong>Posted:</strong> 06-Jun-2007 at 3:10pm<br /><br /><P =Questi&#111;n style="MARGIN: 0in 0in 0pt"><strong><EM><FONT face="Times New Roman" size=3>Answer:</FONT></EM></strong></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT face="Times New Roman" size=2>Naturally, the answer depends upon the specific problems you’re having, but there are a few we see over and over again, so let’s just walk through the scenarios.</FONT></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT face="Times New Roman" size=2>There are two major variables:</FONT></P><OL style="MARGIN-TOP: 0in" =1><LI =Ms&#111;normal style="MARGIN: 8pt 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in"><FONT face="Times New Roman" size=2>Whether the list feeding the child grid is a ReadOnlyEntityList or a vanilla EntityList; and</FONT></LI><LI =Ms&#111;normal style="MARGIN: 8pt 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in"><FONT face="Times New Roman" size=2>What UI mechanism you wish to give the end user to indicate that she wants to add a record.</FONT></LI></OL><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT size=2><FONT face="Times New Roman">For discussion we’ll use our familiar standby from our tutorials, a Master-Detail form that displays properties of an Employee in loose controls, and the Employee’s Orders in a grid:<SPAN style="mso-spacerun: yes">&nbsp; </P><DIV></DIV><DIV></DIV><DIV></DIV><P><img src="http://www.ideablade.com/Forum/uploads/20070606_180926_SNAG-0021.jpg" height="604" width="691" border="0" /></P><H4 style="MARGIN: 12pt 0in 3pt -0.25in"><A name=_Toc162438381><strong><FONT size=3>ReadOnlyEntityList v. EntityList</FONT></strong></A></H4><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">If you have chained the Employees and Orders BindingSources (as demonstrated in the Fundamentals tutorials), then in effect you are using the list of Orders returned by the current Employee’s Orders property to feed the child grid.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Let’s look at code generated (into the EmployeeDataRow class) for this property by the DevForce Object Mapper:</P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p>&nbsp;</o:p></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT style=": #e6e6e6"><strong><FONT face="Courier New"><SPAN style="mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#808080>&nbsp;&nbsp;&nbsp; </FONT></SPAN></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">public</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080> </FONT></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">virtual</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080> </FONT></SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">ReadOnlyEntityList</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080>&lt;</FONT></SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">Order</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080>&gt; Orders {<o:p></o:p></FONT></SPAN></FONT></strong></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT style=": #e6e6e6"><strong><FONT face="Courier New"><SPAN style="mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#808080>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">get</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080> { <o:p></o:p></FONT></SPAN></FONT></strong></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT style=": #e6e6e6"><strong><FONT face="Courier New"><SPAN style="mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#808080>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN></SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">ReadOnlyEntityList</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080>&lt;</FONT></SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">Order</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080>&gt; result_;<o:p></o:p></FONT></SPAN></FONT></strong></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT style=": #e6e6e6"><strong><FONT face="Courier New"><SPAN style="mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#808080>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">if</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080> (GetInterceptor&lt;</FONT></SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">ReadOnlyEntityList</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080>&lt;</FONT></SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">Order</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080>&gt;&gt;(</FONT></SPAN><SPAN style="COLOR: maro&#111;n; mso-no-proof: yes">"Orders"</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080>, GetOrdersCore, </FONT></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">out</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080> result_)) </FONT></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">return</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080> result_;<o:p></o:p></FONT></SPAN></FONT></strong></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT style=": #e6e6e6"><strong><FONT face="Courier New"><SPAN style="mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#808080>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">return</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080> GetOrdersCore();<o:p></o:p></FONT></SPAN></FONT></strong></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="mso-no-proof: yes"><FONT color=#808080><FONT style=": #e6e6e6"><strong><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></FONT></strong></FONT></FONT></SPAN></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="mso-no-proof: yes"><strong><FONT color=#808080><FONT style=": #e6e6e6"><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}</FONT></FONT></FONT></strong></SPAN></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">For the purpose of this discussion, the details of the above code are irrelevant, <I style="mso-bidi-font-style: normal">except for the fact that</I> <I style="mso-bidi-font-style: normal">it returns a ReadOnlyEntityList</I>.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>That a list is a ReadOnlyEntityList rather than a vanilla EntityList does <I style="mso-bidi-font-style: normal">not</I> mean that changes cannot be made to the details of a given Order included in such a list: rather, it means that you cannot <I style="mso-bidi-font-style: normal">directly</I> add new Orders to the list, or delete existing Orders from it.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In other words, you cannot execute the second of the following two statements:</P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><o:p>&nbsp;</o:p></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT style=": #e6e6e6"><strong><FONT face="Courier New"><SPAN style="mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#808080>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN></SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">Order</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080> newOrder = </FONT></SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">Order</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080>.Create(mPersMgr,mCurrentEmployee);<o:p></o:p></FONT></SPAN></FONT></strong></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><SPAN style="mso-no-proof: yes"><strong><FONT color=#808080><FONT style=": #e6e6e6"><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>mCurrentEmployee.Orders.Add(newOrder);<o:p></o:p></FONT></FONT></FONT></strong></SPAN></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">Neither can you execute this statement:<BR style="mso-special-character: line-break"><BR style="mso-special-character: line-break"></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><strong><FONT face="Courier New"><SPAN style="mso-no-proof: yes"><FONT color=#808080><FONT style=": #e6e6e6"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>mCurrentEmployee.Orders.Remove((</FONT></FONT></SPAN><FONT style=": #e6e6e6"><SPAN style="COLOR: teal; mso-no-proof: yes">Order</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080>)(mOrdersBS.Current));<o:p></o:p></FONT></SPAN></FONT></FONT></strong></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">So how do you get a new Order into the list, or remove an existing one from it?<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Actually, it is very easy, because it also so happens that DevForce automatically configures a ListManager for any list that is returned by a generated relation property. That ListManager watches the PersistenceManager cache for Orders that should be included in the list.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>When any such Order appears in the cache (whether by virtue of being newly added to the cache, or modified so that it suddenly belongs to the current Employee), the ListManager makes sure it gets included in the list. When any Order already in the list disappears from the cache, or is modified so that it no longer belongs to the current Employee, it is automatically removed from the list.</P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">So to add a new item to mCurrentEmployee.Orders, you simply add to the PersistenceManager’s cache an Order whose EmployeeId connects it to the current Employee:<BR style="mso-special-character: line-break"><BR style="mso-special-character: line-break"></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><strong><FONT style=": #e6e6e6"><FONT face="Courier New"><SPAN style="mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#808080>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN></SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">Order</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080> newOrder = </FONT></SPAN><SPAN style="COLOR: teal; mso-no-proof: yes">Order</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080>.Create(mPersMgr, mCurrentEmployee);<o:p></o:p></FONT></SPAN></FONT></FONT></strong></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">…or you change the EmployeeId of an existing Order so that it now points to the current Employee: <BR style="mso-special-character: line-break"><BR style="mso-special-character: line-break"></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><strong><FONT color=#808080><FONT style=": #e6e6e6"><FONT face="Courier New"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>someOrder.Employee = mCurrentEmployee;</FONT></FONT></FONT></strong></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">Similarly, to delete an existing Order, you do the following:<BR style="mso-special-character: line-break"><BR style="mso-special-character: line-break"></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><strong><FONT face="Courier New"><SPAN style="mso-no-proof: yes"><FONT color=#808080><FONT style=": #e6e6e6"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>((</FONT></FONT></SPAN><FONT style=": #e6e6e6"><SPAN style="COLOR: teal; mso-no-proof: yes">Order</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080>)(mOrdersBS.Current)).Delete();<o:p></o:p></FONT></SPAN></FONT></FONT></strong></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">In all cases, the mCurrentEmployee.Orders ReadOnlyEntityList will get updated automatically and instantaneously to reflect the new state of the current Employee’s Orders collection.</P><H5 style="MARGIN: 12pt 0in 3pt"><EM><FONT size=4>Is There Any Down Side to Chaining BindingSources, or Otherwise Using a Parent’s Relation Property to Obtain a List of Child Items?</FONT></EM></H5><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">You are fairly likely to encounter situations where getting your child items from a relation property of the parent will not do what you need. For example, you may need to filter the child items, only showing those that meet an additional condition (above and beyond simply belonging to the particular parent); or you may wish to use a span query when retrieving the children so that you pre-fetch additional parts of their object graphs.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In such situations you must cook your own list.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">You still have the choice of using your own ReadOnlyEntityList with a ListManager that you configure; or of using an EntityList, with or without a ListManager.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The one choice you <I style="mso-bidi-font-style: normal">don’t</I> have is to instantiate your own ReadOnlyEntityList but not provide a ListManager for it.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>If you do that, you’ll have no way of altering the contents of the list for an add or delete.</P><H4 style="MARGIN: 12pt 0in 3pt -0.25in"><A name=_Toc162438382><strong><FONT size=3>UI Mechanisms for Add &amp; Delete</FONT></strong></A></H4><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">A second important branch in your implementation decision for adding items to a child grid lies in your choice of UI mechanism.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Basically, there are three choices:</P><OL style="MARGIN-TOP: 0in" =1><LI =Ms&#111;normal style="MARGIN: 8pt 0in 0pt; mso-list: l1 level1 lfo1; tab-stops: list .5in">Use a conventional, stand-alone button; or</LI><LI =Ms&#111;normal style="MARGIN: 8pt 0in 0pt; mso-list: l1 level1 lfo1; tab-stops: list .5in">Use the AddNewItem and DeleteItem buttons on a BindingNavigator; or </LI><LI =Ms&#111;normal style="MARGIN: 8pt 0in 0pt; mso-list: l1 level1 lfo1; tab-stops: list .5in">Use the grid’s NewItem row for adds, and a combination of selecting the row and pressing the <?:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:place w:st="&#111;n"><st1:State w:st="&#111;n">DEL</st1:State></st1:place> key for deletions.</LI></OL><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">Naturally, there are other choices, but most are adequately represented by the choice of a stand-alone button.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The important characteristics of that mechanism is that it </P><OL style="MARGIN-TOP: 0in" =1 start=3><UL style="MARGIN-TOP: 0in" =disc><LI =Ms&#111;normal style="MARGIN: 8pt 0in 0pt; mso-list: l1 level2 lfo1; tab-stops: list 1.0in">generates an event that can be handled, and </LI><LI =Ms&#111;normal style="MARGIN: 8pt 0in 0pt; mso-list: l1 level2 lfo1; tab-stops: list 1.0in">doesn’t attempt to do anything on its own.</LI></UL></OL><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">As you will see, choices 2 and 3 don’t meet the second criterion:<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>they <I style="mso-bidi-font-style: normal">do</I> attempt, somewhat unhelpfully, to do things on their own; and their built-in behaviors must be either disarmed, or danced around, to get proper behavior with cached objects.</P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">We’ll take the three approaches in order.</P><H5 style="MARGIN: 12pt 0in 3pt"><EM><FONT size=4>Using Conventional, Stand-Alone Buttons</FONT></EM></H5><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">In this approach you provide a stand-alone Button control to the user to indicate when she wants to add a child record, and another button for deletes.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>With this approach you have but two things to worry about:</P><OL style="MARGIN-TOP: 0in" =1><LI =Ms&#111;normal style="MARGIN: 8pt 0in 0pt; mso-list: l0 level1 lfo2; tab-stops: list .5in">Making the button do the indicated action, and </LI><LI =Ms&#111;normal style="MARGIN: 8pt 0in 0pt; mso-list: l0 level1 lfo2; tab-stops: list .5in">Making sure the Enabled state of the button is appropriate for the application context.</LI></OL><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">By the second part, we mean, for example, that the Delete button should not be enabled when there are no items in the list; and the Add button <I style="mso-bidi-font-style: normal">should</I> be enabled whenever adding a record is a reasonable thing to do. (It may be sufficient just to make sure the Add button is always enabled.)<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>To disable the Delete button, use the ListChanged event of the BindingSource that supplies the grid with data.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In the handler for that event, check the count on items in the list; if it’s zero, disable the button.</P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">So what about making the button perform the indicated action?<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Well, an <B style="mso-bidi-font-weight: normal">Add</B> button should call the Create method in the child entity’s class, e.g., Order.Create().<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Then, depending upon whether the list into which that new child is to be included is managed, or not, it may be necessary to explicitly add the new Order to the list.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Maybe you also want to call MoveLast() on the BindingSource to which the entities in the list are delivered. That’s about it.</P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">The <B style="mso-bidi-font-weight: normal">Delete</B> button should call the Delete() method on whatever child entity is currently selected in the grid. That entity is a DevForce business object, so a side-effect of invoking its Delete() method will be that it is removed from any BindableLists (EntityLists, ReadOnlyEntityLists) in which it is currently included.</P><H5 style="MARGIN: 12pt 0in 3pt"><EM><FONT size=4>Using the AddNewItem and DeleteItem Buttons on a BindingNavigator</FONT></EM></H5><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">This approach is similar to that of using stand-alone buttons, but with the additional wrinkle that the built-in behaviors of the buttons must first be disabled.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>What are these built-in behaviors?<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Well, the <B style="mso-bidi-font-weight: normal">AddNewItem</B> button wants to create a new item by calling a parameterless constructor on the type; but that’s a problem, because DevForce entities, for very good reasons, <I style="mso-bidi-font-style: normal">have</I> no parameterless constructor!<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>The <B style="mso-bidi-font-weight: normal">DeleteItem</B> button, for its part, wants to remove an item from the list that feeds the BindingNavigator’s BindingSource; but when we call Delete() on the selected object, DevForce will see to it that it’s also removed from that list.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>We definitely don’t want <I style="mso-bidi-font-style: normal">two</I> different things each removing an item from the list!<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">Fortunately, disabling the default behaviors is easy.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Just include the following two statements somewhere in your start-up code for the form or UserControl:</P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><o:p>&nbsp;</o:p></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><FONT style=": #e6e6e6"><strong><FONT face="Courier New"><SPAN style="mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#808080>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">this</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080>.mEmployeesBindingNavigator.AddNewItem = </FONT></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">null</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080>;<o:p></o:p></FONT></SPAN></FONT></strong></FONT></P><P =CodeSnippet style="MARGIN: 0in 0in 0pt 0.25in"><strong><FONT style=": #e6e6e6"><FONT face="Courier New"><SPAN style="mso-no-proof: yes"><SPAN style="mso-spacerun: yes"><FONT color=#808080>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">this</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080>.mEmployeesBindingNavigator.DeleteItem = </FONT></SPAN><SPAN style="COLOR: blue; mso-no-proof: yes">null</SPAN><SPAN style="mso-no-proof: yes"><FONT color=#808080>;<o:p></o:p></FONT></SPAN></FONT></FONT></strong></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">By default, the AddNewItem and DeleteItem buttons of said BindingNavigator are assigned to these two properties, respectively.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Once you null them out, those buttons no longer have associated with them any behaviors other than the ones you explicitly code into them.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>At that point, programming them becomes exactly the same exercise as in the stand-alone buttons case.</P><H5 style="MARGIN: 12pt 0in 3pt"><EM><FONT size=4>Using the NewItem Row for Adds, and Select / <st1:place w:st="&#111;n"><st1:State w:st="&#111;n">DEL</st1:State></st1:place> for Deletions</FONT></EM></H5><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">The NewItem row for a grid is that row at the bottom or top of the grid –some vendors let you choose where it lives – the clicking into which causes a new item to be added.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Typically, this row is labelled with an asterisk (*) to indicate its special purpose. You have to set a couple of properties – on the grid, on the list that supplies it, or both – to get this row to show up in the first place; then you have to override or augment what it tries to do for you.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>In the case of deleting, you have to handle a grid event.</P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt">The details of doing these things are specific to the brand of grid you’re using: .NET, Developer Express, and Infragistics all require slightly different approaches.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>These are beyond the scope of this discussion, but are detailed in an article, “Add Delete Child Business Objects in a Grid Using NewItem Row”, included in the “Add-Delete On Child Grid” instructional unit that is shipped with the product (in the 200 Intermediate series of instructional units).</P><P></SPAN></FONT></FONT>&nbsp;</P>]]>
   </description>
   <pubDate>Wed, 06 Jun 2007 15:10:55 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=59&amp;PID=131#131</guid>
  </item> 
  <item>
   <title>Adding Items to a Child Grid : Question:  On my master-detail...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=59&amp;PID=130#130</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=20" rel="nofollow">Customer</a><br /><strong>Subject:</strong> 59<br /><strong>Posted:</strong> 06-Jun-2007 at 3:06pm<br /><br /><P =Questi&#111;n style="MARGIN: 0in 0in 0pt"><strong><EM><FONT face="Times New Roman" size=3>Question: </FONT></EM></strong></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><FONT face="Times New Roman" size=2>On my master-detail form, I want my user to be able to add detail (child) elements, but I’m having problems implementing this successfully. How can I do this?</FONT></P><P =Ms&#111;normal style="MARGIN: 8pt 0in 0pt"><?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p><FONT face="Times New Roman" size=2>&nbsp;</FONT></o:p></P>]]>
   </description>
   <pubDate>Wed, 06 Jun 2007 15:06:29 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=59&amp;PID=130#130</guid>
  </item> 
 </channel>
</rss>