Skip to content
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

Merged
merged 4 commits into from
Aug 10, 2022
Merged

Walkthrough for Get Started with WinForms #3968

merged 4 commits into from
Aug 10, 2022

Conversation

ajcvickers
Copy link
Member

Fixes #778
Part of #2137

@ajcvickers
Copy link
Member Author

@merriemcgaw @KlausLoeffelmann This is a walkthrough for Windows Forms data binding using EF Core. Feedback appreciated!

@ajcvickers ajcvickers changed the title Walk-through for Get Started with WinForms Walkthrough for Get Started with WinForms Aug 4, 2022
Copy link
Member

@KlausLoeffelmann KlausLoeffelmann left a 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!

entity-framework/core/get-started/winforms.md Outdated Show resolved Hide resolved

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.
Copy link
Member

@KlausLoeffelmann KlausLoeffelmann Aug 4, 2022

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**.
Copy link
Member

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`.
Copy link
Member

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();
Copy link
Member

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?

ajcvickers and others added 3 commits August 5, 2022 17:39
Co-authored-by: Klaus Löffelmann <9663150+KlausLoeffelmann@users.noreply.github.com>
@ajcvickers
Copy link
Member Author

@KlausLoeffelmann Thanks for taking a look. I've updated the terminology, while not trying to use too many terms to keep it readable. :-)

Copy link
Member

@KlausLoeffelmann KlausLoeffelmann left a 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!

@ajcvickers
Copy link
Member Author

@JeremyLikness @bricelam Do either of you want to take a look at this before I merge?

@JeremyLikness
Copy link
Member

@ajcvickers Yes, if you can give me until noon today

Copy link
Contributor

@bricelam bricelam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Member

@JeremyLikness JeremyLikness left a 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!

@ajcvickers ajcvickers merged commit e951e15 into main Aug 10, 2022
@ajcvickers
Copy link
Member Author

Thanks, all. I have to say it was a pleasure doing this. I love WinForms!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create samples for databinding using EF Core in WPF and WinForms
4 participants