-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Walkthrough for Get Started with WinForms #3968
Conversation
@merriemcgaw @KlausLoeffelmann This is a walkthrough for Windows Forms data binding using EF Core. Feedback appreciated! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so cool, thanks for writing this up!
There was one terminology issue, which I commented on.
I love it!
|
||
The next step is to connect the `Product` and `Category` types from the model to the `DataGridView` controls. This will bind the data loaded by EF Core to the controls, such that the entities tracked by EF Core are kept in sync with those displayed in the controls. | ||
|
||
1. Click the **Design Binding Picker** on the first `DataGridView`. This is the tiny button at the top-right corner of the control. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit of terminology: The tiny button is the Designer Action Glyph. You open the Action List with it (which is what you described as the Design Binding Picker), and then you get access to the Design Binding Picker, by accessing the type editor of the DataSource property. A Type Editor is either the value picker provided by the drop-down of a property in the Property Browser or a modal dialog to edit the type - also initiated through a property in that browser (then with the three-dotted button). The most frequently used Typed Editors of a control's properties can - like here - also be invoked via its Action List. The Design Binding Picker is technically only the content of that drop down in this case. (Terminology in WinForms is confusing, I know - we always use the euphemism "WinForm's terminology has historically grown"! 😄)
> [!TIP] | ||
> If no data source types appear here, then make sure that `Product.cs`, `Category.cs` and `ProductsContext.cs` have been added to the project _**and the solution has been built**_. | ||
|
||
4. Back in the **Design Binding Picker**, choose **Choose Data Source**, **Other Data Sources**, **Project Data Sources**, and finally **Category**. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here for the correct terminology.
|
||
The second `DataGridView` will be bound to products. However, rather than binding to the top-level `Product` type, it will instead be bound to the `Products` navigation from the `Category` binding of the first `DataGridView`. This means that when a category is selected in the first view, the products for that category will automatically be used in the second view. | ||
|
||
5. Using the **Design Binding Picker** on the second `DataGridView`, choose **Choose Data Source**, then expand the `categoryBindingSource` and choose `Products`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here.
|
||
this.dbContext = new ProductsContext(); | ||
|
||
//this.dbContext.Database.EnsureDeleted(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to add a comment for this?
Co-authored-by: Klaus Löffelmann <9663150+KlausLoeffelmann@users.noreply.github.com>
@KlausLoeffelmann Thanks for taking a look. I've updated the terminology, while not trying to use too many terms to keep it readable. :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look real good to me now!
Thanks for the write up!
@JeremyLikness @bricelam Do either of you want to take a look at this before I merge? |
@ajcvickers Yes, if you can give me until noon today |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I laughed. I cried. I started a fan club. This is great!
Thanks, all. I have to say it was a pleasure doing this. I love WinForms! |
Fixes #778
Part of #2137