<?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 : Edit a related object in another form</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : Edit a related object in another form</description>
  <pubDate>Sun, 19 Apr 2026 05:53:17 -700</pubDate>
  <lastBuildDate>Sun, 13 Apr 2008 23:33:57 -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=759</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>Edit a related object in another form : Thank yo for reply.  First missing...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=759&amp;PID=2822#2822</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=45" rel="nofollow">erturkcevik</a><br /><strong>Subject:</strong> 759<br /><strong>Posted:</strong> 13-Apr-2008 at 11:33pm<br /><br /><DIV>Thank yo for reply.</DIV><DIV>&nbsp;</DIV><DIV>First missing declared GetCustomer();</DIV><DIV>I'm develop mdi application.</DIV><DIV>Edit for using Show() mode.</DIV><DIV>User may open edit form count 1 to record count of TblKasa.</DIV><DIV>Because of separate PM on each editing form for user cancel edit (PM.Rejectchanges).</DIV><DIV>&nbsp;</DIV><DIV>Best Regards</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Sun, 13 Apr 2008 23:33:57 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=759&amp;PID=2822#2822</guid>
  </item> 
  <item>
   <title>Edit a related object in another form : There are probably other ways...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=759&amp;PID=2820#2820</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=202" rel="nofollow">BillG</a><br /><strong>Subject:</strong> 759<br /><strong>Posted:</strong> 13-Apr-2008 at 11:16am<br /><br /><P>There are probably other ways and better ways to do this but this works well for me and it seems not to violate MVC too bad :)</P><DIV></DIV><DIV></DIV><P>//CustomersListForm.cs</P><P>public class CustomersListForm<BR>{<BR>&nbsp;&nbsp;&nbsp; private CustomerController myController;</P><P>&nbsp;&nbsp;&nbsp; public CustomersListForm()<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InitializeComponents();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myController = new CUstomer Controller();<BR>&nbsp;&nbsp;&nbsp; }</P><P>&nbsp;&nbsp;&nbsp; private void CustomersListForm_Load(object sender, EventArgs e)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PopulateCustomerGrid();<BR>&nbsp;&nbsp;&nbsp; }</P><P>&nbsp;&nbsp;&nbsp; public void PopulateCustomerGrid()<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; customersGrid.DataSource = myController.GetCustomers();<BR>&nbsp;&nbsp;&nbsp; }</P><P>&nbsp;&nbsp;&nbsp; private void CustomersGrid_SelChange(object sender, EventArgs e)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(CustomersGrid.RowSel != -1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;Int32 customerId = Int32.Parse(CustomersGrid&#091;CustomersGrid.RowSel,1&#093;.ToString();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myController.GetCustomerById(customerId);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; }</P><P>&nbsp;&nbsp;&nbsp; public void EditCustomer()<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CustomerForm form = new CustomerForm(myController);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; form.ShowDialog();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PopulateCustomerGrid();<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; }</P><P>&nbsp;&nbsp;&nbsp; public void AddCustomer()<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;myController.CreateCustomer();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CustomerForm form = new CustomerForm(myController);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; form.ShowDialog();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PopulateCustomerGrid();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; }</P><P>}</P><P><BR>// CustomerController.cs</P><P>public class CustomerController<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private Customer currentCustomer;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private PersistenceManager myPM = PersistenceManager.DefaultManager;</P><P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Customer CurrentCustomer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return currentCustomer;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; currentCustomer = value;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</P><P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void CreateCustomer()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;currentMember = Customer.Create(myPM);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</P><P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void GetCustomerById(Int32 customerId)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RdbQuery query = new RdbQuery(typeof(Customer));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; query.AddClause(Customer.CustomerIdEntityColumn, EntityQueryOp.EQ, customerId);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; currentCustomer = myPM.GetEntity&lt;Customer&gt;(query);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</P><P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void SaveCustomer()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myPM.SaveChanges();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch(SaveException ex)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</P><P>}</P><P><BR>// CustomerForm.cs</P><P>public class CustomerForm<BR>{<BR>&nbsp;private CustomerController myController;</P><P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public CustomerForm(CustomerController controller)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InitializeComponents();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myController = controller;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</P><P>&nbsp;&nbsp; &nbsp;private void CustomerForm_Load(object sender, EventArgs e)<BR>&nbsp;&nbsp;&nbsp; &nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CustomerBS.DataSource = myController.CurrentCustomer;<BR>&nbsp;&nbsp;&nbsp; &nbsp;}</P><P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private void SaveButton_Click(object sender, EventArgs e)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myController.SaveCustomer();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; this.Close();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</P><P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </P><span style="font-size:10px"><br /><br />Edited by BillG - 13-Apr-2008 at 11:19am</span>]]>
   </description>
   <pubDate>Sun, 13 Apr 2008 11:16:48 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=759&amp;PID=2820#2820</guid>
  </item> 
  <item>
   <title>Edit a related object in another form : Hi;   TblKasa (ID, Code, Name)...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=759&amp;PID=2791#2791</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=45" rel="nofollow">erturkcevik</a><br /><strong>Subject:</strong> 759<br /><strong>Posted:</strong> 09-Apr-2008 at 8:24am<br /><br />Hi; <DIV>&nbsp;</DIV><DIV>TblKasa (ID, Code, Name)&nbsp; <BR></DIV><DIV>&nbsp;&nbsp; I have created a Browse Form with the DataGridView to present the records.<BR>&nbsp;&nbsp; I don't want the user to edit or insert records using the DataGridView (so editing is disabled in this form). <BR>&nbsp;&nbsp; I have provided three buttons to this form (Insert Record, Change Record and Delete Record). <?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><O:P></O:P></DIV><P><FONT face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt">&nbsp; When I click Add or Edit, a second form is open to create a new Kasa or edit the selected one.<BR>&nbsp; Of course, if the user cancel the frmKasa form, the record is not added or edited.<BR>&nbsp; I want <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - How to passing/accessing selected record from browse form one form in another form<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - After that he saves the changes (PM.SaveChanges) and the current form is closing and the old form with the<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataGridView gets the focus again. At the point the user is saving the data I want to refresh the data in<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the form with the DataGridView. if the added record I have setting position added record in datagrid.</P><DIV></DIV><DIV></DIV><DIV>Please&nbsp;send me&nbsp;example code or application.</DIV><DIV>&nbsp;</DIV><DIV>Thank you for any help me.</DIV><DIV>&nbsp;</DIV><DIV>Platform Windowsforms C#&nbsp;.Net 2&nbsp;&nbsp;</DIV><DIV>&nbsp;</DIV><DIV><DIV></DIV><DIV></DIV>Best Regards</DIV><DIV></DIV><P></SPAN></FONT>&nbsp;</P><span style="font-size:10px"><br /><br />Edited by erturkcevik - 09-Apr-2008 at 8:32am</span>]]>
   </description>
   <pubDate>Wed, 09 Apr 2008 08:24:11 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=759&amp;PID=2791#2791</guid>
  </item> 
 </channel>
</rss>