+2007-05-03 Chris Toshok <toshok@ximian.com>
+
+ * CurrencyManager.cs (CurrencyManager.ListChangeHandler): in the
+ 2.0 block, pass listposition + 1 to ChangeRecordState when a row
+ was added before the current listposition. Fixes the
+ TestInsertRowBeforeCurrent unit test.
+
2007-05-03 Jonathan Pobst <monkey@jpobst.com>
* Application.cs: Add RaiseIdle.
if (listposition >= list.Count)
listposition = list.Count - 1;
- if (listposition != -1)
+ if (old_index != -1 && listposition != -1)
OnCurrentChanged (EventArgs.Empty);
if (firePositionChanged)
ChangeRecordState (e.NewIndex,
false, false, true, false);
+#if ONLY_1_1
+ UpdateIsBinding ();
+#else
OnItemChanged (new ItemChangedEventArgs (-1));
+#endif
}
else {
#if NET_2_0
if (e.NewIndex <= listposition) {
- ChangeRecordState (listposition,
+ ChangeRecordState (listposition + 1,
false, false, false, false);
OnItemChanged (new ItemChangedEventArgs (-1));
OnPositionChanged (EventArgs.Empty);
[Test]
public void TestInsertRowBeforeCurrent ()
{
-#if NET_2_0
- if (TestHelper.RunningOnUnix) {
- Assert.Ignore ("Fails with 2.0 profile");
- }
-#endif
Control c = new Control ();
c.CreateControl ();
Binding binding;
Assert.AreEqual (2, cm.Count, "5");
}
+ [Test]
+ public void CancelAddNew ()
+ {
+ if (TestHelper.RunningOnUnix) {
+ Assert.Ignore ("Fails at the moment");
+ }
+
+ Control c = new Control ();
+ c.CreateControl ();
+ Binding binding;
+ CurrencyManager cm;
+
+ DataSet dataSet1 = new DataSet();
+ dataSet1.Tables.Add();
+ dataSet1.Tables[0].Columns.Add();
+
+ c.BindingContext = new BindingContext ();
+ cm = (CurrencyManager) c.BindingContext[dataSet1, dataSet1.Tables[0].TableName];
+ binding = c.DataBindings.Add ("Text", dataSet1.Tables[0], dataSet1.Tables[0].Columns[0].ColumnName);
+
+ HookupCurrencyManager (cm);
+#if WITH_BINDINGS
+ HookupBinding (binding);
+#endif
+ event_log = "";
+ event_num = 0;
+
+ cm.AddNew ();
+
+ cm.CancelCurrentEdit ();
+
+ Console.WriteLine (event_log);
+
+ Assert.AreEqual (
+#if NET_2_0
+ "0: PositionChanged (to 0)\n1: CurrentChanged\n2: CurrentItemChanged\n3: ItemChanged (index = -1)\n4: ItemChanged (index = -1)\n5: PositionChanged (to -1)\n6: ItemChanged (index = -1)\n7: PositionChanged (to -1)\n8: CurrentChanged\n9: CurrentItemChanged\n10: ItemChanged (index = -1)\n11: ItemChanged (index = -1)\n",
+#else
+ "0: PositionChanged (to 0)\n1: CurrentChanged\n2: ItemChanged (index = -1)\n3: ItemChanged (index = -1)\n4: CurrentChanged\n5: PositionChanged (to -1)\n6: ItemChanged (index = -1)\n7: ItemChanged (index = -1)\n8: ItemChanged (index = -1)\n",
+#endif
+ event_log, "1");
+
+ }
+
}
[TestFixture]