[Mono-dev] Patches for mono-winforms

Steven Boswell II ulatekh at yahoo.com
Sun Jun 3 02:58:14 UTC 2012

Rob, you're my hero.  Very few tests in DataGridViewTest.cs create a Form, but most of the ones that do involve data binding.
I added a Form to my test, and it succeeded immediately.  Apparently, Application.Run() isn't necessary, but that was a good idea.
Enclosed is a revised patch, for review by the Powers That Be.

Steven Boswell

 From: Rob Wilkens <robwilkens at gmail.com>
To: mono-devel-list at lists.ximian.com 
Sent: Saturday, June 2, 2012 6:46 PM
Subject: Re: [Mono-dev] Patches for mono-winforms

On 06/02/2012 09:38 PM, Rob Wilkens wrote: 
On 06/02/2012 08:55 PM, Steven Boswell II wrote: 
>The EditingControlShowing event has to be called, and it has to be called after the control's contents have been initialized properly...that's not really two separate issues.
>>The enclosed patch is an updated version; in addition to having a unit test, it fixes one additional bug revealed by my testing. Before, DataGridViewComboBoxCell.InitializeEditingControl() was setting the initial value from the FormattedValue property, instead of the initialFormattedValue parameter.
>>I tried to write an additional unit test that worked with bound data, but for the life of me I can't figure out why it doesn't work.  I've done data-binding with DataGridView before...it wasn't this mysterious.  In my unit test, after I set the DataGridView's DataSource property, the data-grid doesn't initialize properly; instead of four rows, it ends up with one row, and all its cell values are null.  After beating my head against the wall for several hours, I'm perfectly happy to be told what a moron I am, if someone will just tell me why the EditingControlShowingTest_Bound test doesn't work. :-)
>>Steven Boswell
>Not writing to call you a moron, I'm a newbie myself and i could
      be wrong...  But i copied and pasted your test code for
      EditingControlShowingTest_Bound into Visual Studio 2010, but
      rather than creating the DataGridVIew in code i placed it on the
      form and modified your code to use the one on the form...  And i
      disabled the asserts...  And from what i can tell it runs fine in
      both .net and mono (that is, the data grid view populates).
>One thing that I noticed about your code, though, is it depends on
      a 'showing' event..
>And i wonder if that means your datagridview needs to be placed on
      a form which is displayed, so that it is actually shown...
>i.e. change your code something like this:
>using (Form Form1=new Form()){
>    Form1.Controls.Add(_dataGridView);//optionaly set sizeand
      location of both gridview and form
>    Form1.Show();
>    ... insert the rest of your code here .... 
Oh, and if i'm right, you might need the equivalent of an Application.Run(Form1) to process the events since you're listening for events, just don't forget to close Form1 or the Run loop might never end and your test can hang up with a displayed window...

Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20120602/824504a8/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mwf-01-DataGridView-EditingControlShowing.patch.bz2
Type: application/octet-stream
Size: 3196 bytes
Desc: not available
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20120602/824504a8/attachment-0001.obj>

More information about the Mono-devel-list mailing list