开发者

MS Access Datasheet View vs .NET DataGridView - Newbie Questions

开发者 https://www.devze.com 2023-02-11 06:05 出处:网络
I\'m trying to migrate (mostly mentally at this point) from MS Access to .NET for database programming. I\'ve found one of the first tests to be fairly painful. I\'m trying to recreate MS Access\'s da

I'm trying to migrate (mostly mentally at this point) from MS Access to .NET for database programming. I've found one of the first tests to be fairly painful. I'm trying to recreate MS Access's datasheet view in Visual Studio.

Features I use in MS Access Datasheet View that I haven't immediately found in the DataGridView. I'm wondering if anyone can help me out here. I'm assuming that a DataGridView will be used to edit records as opposed to being used as a search/list only.

1) Form Level BeforeUpdate Event - Here I typically run validation code

2) Textbox level BeforeUpdate Event - If I'm feeling anal I'll run validation code here.

3) In MS Access you can sort by multiple columns at once

4) In MS Access columns positioning, sort order, width, row height, etc. are properties that can be saved in your user's settings (text file or table) and reloaded next time they open the form.

5) In MS Access you can refer to one of the form's recordset fields like this: Me!dteDateTimeEntered = Now() This allows you to edit/enter certain types of data without having to show it to the user.

6) Moving from one row to another automatically saves the changes you made to the record you just exited (assuming you made some changes). It's unclear to me if .NET DataGridView works this same way or if this is something that is determined by the code you use.

7) I often program so that the user can double click in a cell and get a certain action such as dialing a phone number, opening Outlook with an email address inserted, bringing up a windows folder or a picture viewer, or opening a single-record details form. In order to do this I usually grab the primary key of 开发者_开发问答the current record using code like: Me!ContactID or the data from the cell they double clicked in. How can I get this data for the current record in a DataGridView?

8) In MS Access DataSheet view you create textboxes and bind them to specific fields, then you usually name them like txtFirstName. This way you can refer to the value of the textbox using Me.txtFirstName.Value or Me.txtFirstName.Text or you might also choose to refer to the value of the recordset field using Me!FirstName. It appears that .NET's paradigm is totally different so I'm confused. May I create bound textboxes in a DataGridView?


Have you spent some time looking at the documentation for the DataGridView? A quick glance at it seems to answer most of your questions more or less prima facie.

You will have much finer control over many of the items in your wishlist in .net than with VBA. You may also find that the native .net controls are a bit clunky, and prefer to use someone's enhanced control. For data lists in Winforms, for example, I've found Philip Piper's ObjectListView very elegant, extensible and time-saving for handling pretty much everything in your wishlist.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号