© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
19 replies
Wisch10

Is there a way to return or access a class object created inside a public partial class (form) from

I have a process that allows expenses to be added from a form, and a separate process to add an asset from a form. I would like to add a combination of the two if the expense is for an asset but to run the db inserts in the same function so that if one fails, both are rolled back. I created my second asset form to accept the values for price, purchase date, and payment type and have that only being generated when the expense type is an asset.

FrmAssetFromExpense frmAssetFromExpense = new(expenseDate, amount, type);
fromAssetFromExpense.ShowDialog();

Inside the new form for asset addition, all the items are in place to create the Asset class object from the values entered on the form.

Is there a way to return that Asset object to the main expense form to run a single sql insert?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,828Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Is there a way to block the calling of public method from abstract class inside a derived one?
C#CC# / help
2y ago
❔ accessing object from a class inside of another class
C#CC# / help
3y ago
❔ Access a DataGrid inside a dynamically created TabItem?
C#CC# / help
4y ago
Partial class problem
C#CC# / help
3mo ago