Thoughts from Dan Miser RSS 2.0
 Tuesday, August 01, 2006
After writing a .NET application that used the DataGridView, I noticed that there was no ColumnType drop down to allow the user to easily edit a date/time field. At first, I came across a really good write up on MSDN on how to accomplish this. However, it was written in VB, so I couldn't use it as-is inside my C# application (yes, I could have turned it into an assembly, but then I wouldn't get the chance to learn how things work!). After converting the code to C#, I found that essentially the same thing is now in the core .NET documentation. The main guts of creating a custom column means you need to implement the IDataGridViewEditingControl interface.

After all of this, things went along fairly smoothly in sample applications. Then I plugged it into my real application and scratched my head as I started getting errors about the rowIndex being out of range (ArgumentOutOfRangeException) even though the DataGridView had 5 elements, and the rowIndex being passed in was 0. It turns out this was happening whenever I would check the Value of the cell because the RowIndex was set to -1. This led me to the .NET documentation which talked about the concept of shared rows for the DataGridView. The one sentence summary on shared rows is that they are used in a DataGridView to ease memory use for a bunch of rows that are very similar. There are all sorts of internal rules that determine whether a row can be shared or not, but the long and short of it is that my DataGridView was using shared rows, as was evident from the RowIndex property being set to -1. Since the samples don't take this into account, I changed the code, and now everything is working fine. You can download my modified class to see how I made things work. If you have any feedback on this code, please feel free to leave a comment.

Other references:

Tuesday, August 01, 2006 8:36:00 PM (Central Standard Time, UTC-06:00)  #    Comments [2] -
.NET
Tracked by:
http://9nb-information.info/49369755/index.html [Pingback]
http://9nk-information.info/60875645/index.html [Pingback]
http://9nv-information.info/85833437/aec-software-fasttrack-schedule-review.html [Pingback]
http://9nu-information.info/31760535/index.html [Pingback]
http://9nt-information.info/82013906/ht-s790-home-theater.html [Pingback]
http://9nn-information.info/68328420/index.html [Pingback]
http://9ni-information.info/89192869/index.html [Pingback]
http://9nk-information.info/56848403/index.html [Pingback]
http://9nf-information.info/57070035/index.html [Pingback]
http://9ot-information.info/97622041/health-issues-cebu-phillipines.html [Pingback]
http://9qa-information.info/14370221/index.html [Pingback]
http://9qd-information.info/88502407/index.html [Pingback]
http://9qh-information.info/84454083/index.html [Pingback]
http://9or-information.info/35117580/index.html [Pingback]
http://9qt-information.info/04559293/donna-cinesi-incontri.html [Pingback]
http://9od-information.info/53743774/high-speed-internet-northwood-ohio.html [Pingback]
http://9qd-information.info/80290060/index.html [Pingback]
http://9rv-information.info/54792603/learning-annex-new-york-city-dr-emoto.html [Pingback]
http://9rj-information.info/87399494/mankala-game-board.html [Pingback]
http://9si-information.info/56299467/legge-2-95.html [Pingback]
http://9rx-information.info/60552381/espresso-lavazza-business-opportunity.html [Pingback]
http://9rm-information.info/11501454/index.html [Pingback]
http://9rr-information.info/59128699/index.html [Pingback]
http://9rj-information.info/99457838/index.html [Pingback]
http://9rf-information.info/51381733/management-strategies-used-for-coastal-envi... [Pingback]
http://9uaeb-le-informazioni.info/27100608/argani-eletrico-fune.html [Pingback]
http://9uafl-le-informazioni.info/59209638/foto-robert-powell.html [Pingback]
http://9uafn-le-informazioni.info/03249124/index.html [Pingback]
http://9uaeg-le-informazioni.info/90697731/di-vinci.html [Pingback]
http://9uaer-le-informazioni.info/44955841/index.html [Pingback]
http://9uafp-le-informazioni.info/06464561/index.html [Pingback]
http://9uafl-le-informazioni.info/00154465/index.html [Pingback]
http://9uaea-le-informazioni.info/40310277/index.html [Pingback]
http://9uagn-le-informazioni.info/73708906/umano-troppo-umano.html [Pingback]
http://9uahm-le-informazioni.info/09384185/index.html [Pingback]
http://9uagc-le-informazioni.info/36216826/index.html [Pingback]
http://9uahk-le-informazioni.info/43531463/index.html [Pingback]
http://9uagj-le-informazioni.info/95109729/index.html [Pingback]
http://9uago-le-informazioni.info/82609341/index.html [Pingback]
http://9uahn-le-informazioni.info/84273982/index.html [Pingback]
http://9uahb-le-informazioni.info/18592216/index.html [Pingback]
Navigation
Archive
<August 2008>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008
Dan Miser
Sign In
Statistics
Total Posts: 307
This Year: 22
This Month: 1
This Week: 1
Comments: 604
All Content © 2008, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)