001.
//------------------------------------------------------------------------------
002.
// <copyright file=
"BindingNavigator.cs"
company=
"Microsoft"
>
003.
// Copyright (c) Microsoft Corporation. All rights reserved.
004.
// </copyright>
005.
//------------------------------------------------------------------------------
006.
007.
namespace System.Windows.Forms {
008.
009.
using System;
010.
using System.ComponentModel;
011.
using System.Diagnostics;
012.
using System.Diagnostics.CodeAnalysis;
013.
using System.Drawing;
014.
using System.Globalization;
015.
using System.Runtime.InteropServices;
016.
017.
[
018.
ComVisible(true),
019.
ClassInterface(ClassInterfaceType.AutoDispatch),
020.
DefaultProperty(
"BindingSource"
),
021.
DefaultEvent(
"RefreshItems"
),
022.
Designer(
"System.Windows.Forms.Design.BindingNavigatorDesigner, "
+ AssemblyRef.SystemDesign),
023.
SRDescription(SR.DescriptionBindingNavigator)
024.
]
025.
026.
public class BindingNavigator : ToolStrip, ISupportInitialize {
027.
028.
private BindingSource bindingSource;
029.
030.
private ToolStripItem moveFirstItem;
031.
private ToolStripItem movePreviousItem;
032.
private ToolStripItem moveNextItem;
033.
private ToolStripItem moveLastItem;
034.
private ToolStripItem addNewItem;
035.
private ToolStripItem deleteItem;
036.
private ToolStripItem positionItem;
037.
private ToolStripItem countItem;
038.
039.
private
String
countItemFormat = SR.GetString(SR.BindingNavigatorCountItemFormat);
040.
041.
private EventHandler onRefreshItems = null;
042.
043.
private bool initializing = false;
044.
045.
private bool addNewItemUserEnabled = true;
046.
private bool deleteItemUserEnabled = true;
047.
048.
049.
[EditorBrowsable(EditorBrowsableState.Never)]
050.
public BindingNavigator() : this(false) {
051.
}
052.
053.
054.
public BindingNavigator(BindingSource bindingSource) : this(true) {
055.
BindingSource = bindingSource;
056.
}
057.
058.
[EditorBrowsable(EditorBrowsableState.Never)]
059.
public BindingNavigator(IContainer container) : this(false) {
060.
if (container == null) {
061.
throw new ArgumentNullException(
"container"
);
062.
}
063.
064.
container.Add(this);
065.
}
066.
067.
public BindingNavigator(bool addStandardItems) {
068.
if (addStandardItems) {
069.
AddStandardItems();
070.
}
071.
}
072.
073.
public void BeginInit() {
074.
initializing = true;
075.
}
076.
077.
public void EndInit() {
078.
initializing = false;
079.
RefreshItemsInternal();
080.
}
081.
082.
/// <devdoc>
083.
/// Unhooks the BindingNavigator from the BindingSource.
084.
/// </devdoc>
085.
protected override void Dispose(bool disposing) {
086.
if (disposing) {
087.
BindingSource = null; // ...unwires from events of any prior BindingSource
088.
}
089.
090.
base.Dispose(disposing);
091.
}
092.
093.
public virtual void AddStandardItems() {
094.
095.
//
096.
// Create items
097.
//
098.
099.
MoveFirstItem = new System.Windows.Forms.ToolStripButton();
100.
MovePreviousItem = new System.Windows.Forms.ToolStripButton();
101.
MoveNextItem = new System.Windows.Forms.ToolStripButton();
102.
MoveLastItem = new System.Windows.Forms.ToolStripButton();
103.
PositionItem = new System.Windows.Forms.ToolStripTextBox();
104.
CountItem = new System.Windows.Forms.ToolStripLabel();
105.
AddNewItem = new System.Windows.Forms.ToolStripButton();
106.
DeleteItem = new System.Windows.Forms.ToolStripButton();
107.
108.
ToolStripSeparator separator1 = new System.Windows.Forms.ToolStripSeparator();
109.
ToolStripSeparator separator2 = new System.Windows.Forms.ToolStripSeparator();
110.
ToolStripSeparator separator3 = new System.Windows.Forms.ToolStripSeparator();
111.
112.
char ch = string.IsNullOrEmpty(Name) || char.IsLower(Name[0]) ?
113.
114.
MoveFirstItem.Name = ch +
"indingNavigatorMoveFirstItem"
;
115.
MovePreviousItem.Name = ch +
"indingNavigatorMovePreviousItem"
;
116.
MoveNextItem.Name = ch +
"indingNavigatorMoveNextItem"
;
117.
MoveLastItem.Name = ch +
"indingNavigatorMoveLastItem"
;
118.
PositionItem.Name = ch +
"indingNavigatorPositionItem"
;
119.
CountItem.Name = ch +
"indingNavigatorCountItem"
;
120.
AddNewItem.Name = ch +
"indingNavigatorAddNewItem"
;
121.
DeleteItem.Name = ch +
"indingNavigatorDeleteItem"
;
122.
separator1.Name = ch +
"indingNavigatorSeparator"
;
123.
separator2.Name = ch +
"indingNavigatorSeparator"
;
124.
separator3.Name = ch +
"indingNavigatorSeparator"
;
125.
126.
MoveFirstItem.Text = SR.GetString(SR.BindingNavigatorMoveFirstItemText);
127.
MovePreviousItem.Text = SR.GetString(SR.BindingNavigatorMovePreviousItemText);
128.
MoveNextItem.Text = SR.GetString(SR.BindingNavigatorMoveNextItemText);
129.
MoveLastItem.Text = SR.GetString(SR.BindingNavigatorMoveLastItemText);
130.
AddNewItem.Text = SR.GetString(SR.BindingNavigatorAddNewItemText);
131.
DeleteItem.Text = SR.GetString(SR.BindingNavigatorDeleteItemText);
132.
133.
CountItem.ToolTipText = SR.GetString(SR.BindingNavigatorCountItemTip);
134.
PositionItem.ToolTipText = SR.GetString(SR.BindingNavigatorPositionItemTip);
135.
CountItem.AutoToolTip = false;
136.
PositionItem.AutoToolTip = false;
137.
138.
PositionItem.AccessibleName = SR.GetString(SR.BindingNavigatorPositionAccessibleName);
139.
//
140.
//
Set
up images
141.
//
142.
143.
Bitmap moveFirstImage = new Bitmap(typeof(BindingNavigator),
"BindingNavigator.MoveFirst.bmp"
);
144.
Bitmap movePreviousImage = new Bitmap(typeof(BindingNavigator),
"BindingNavigator.MovePrevious.bmp"
);
145.
Bitmap moveNextImage = new Bitmap(typeof(BindingNavigator),
"BindingNavigator.MoveNext.bmp"
);
146.
Bitmap moveLastImage = new Bitmap(typeof(BindingNavigator),
"BindingNavigator.MoveLast.bmp"
);
147.
Bitmap addNewImage = new Bitmap(typeof(BindingNavigator),
"BindingNavigator.AddNew.bmp"
);
148.
Bitmap deleteImage = new Bitmap(typeof(BindingNavigator),
"BindingNavigator.Delete.bmp"
);
149.
150.
moveFirstImage.MakeTransparent(System.Drawing.Color.Magenta);
151.
movePreviousImage.MakeTransparent(System.Drawing.Color.Magenta);
152.
moveNextImage.MakeTransparent(System.Drawing.Color.Magenta);
153.
moveLastImage.MakeTransparent(System.Drawing.Color.Magenta);
154.
addNewImage.MakeTransparent(System.Drawing.Color.Magenta);
155.
deleteImage.MakeTransparent(System.Drawing.Color.Magenta);
156.
157.
MoveFirstItem.Image = moveFirstImage;
158.
MovePreviousItem.Image = movePreviousImage;
159.
MoveNextItem.Image = moveNextImage;
160.
MoveLastItem.Image = moveLastImage;
161.
AddNewItem.Image = addNewImage;
162.
DeleteItem.Image = deleteImage;
163.
164.
MoveFirstItem.RightToLeftAutoMirrorImage = true;
165.
MovePreviousItem.RightToLeftAutoMirrorImage = true;
166.
MoveNextItem.RightToLeftAutoMirrorImage = true;
167.
MoveLastItem.RightToLeftAutoMirrorImage = true;
168.
AddNewItem.RightToLeftAutoMirrorImage = true;
169.
DeleteItem.RightToLeftAutoMirrorImage = true;
170.
171.
MoveFirstItem.DisplayStyle = ToolStripItemDisplayStyle.Image;
172.
MovePreviousItem.DisplayStyle = ToolStripItemDisplayStyle.Image;
173.
MoveNextItem.DisplayStyle = ToolStripItemDisplayStyle.Image;
174.
MoveLastItem.DisplayStyle = ToolStripItemDisplayStyle.Image;
175.
AddNewItem.DisplayStyle = ToolStripItemDisplayStyle.Image;
176.
DeleteItem.DisplayStyle = ToolStripItemDisplayStyle.Image;
177.
178.
//
179.
//
Set
other random properties
180.
//
181.
PositionItem.AutoSize = false;
182.
PositionItem.Width = 50;
183.
184.
//
185.
// Add items to strip
186.
//
187.
188.
Items.AddRange(new ToolStripItem[] {
189.
MoveFirstItem,
190.
MovePreviousItem,
191.
separator1,
192.
PositionItem,
193.
CountItem,
194.
separator2,
195.
MoveNextItem,
196.
MoveLastItem,
197.
separator3,
198.
AddNewItem,
199.
DeleteItem,
200.
});
201.
}
202.
203.
[
204.
DefaultValue(null),
205.
SRCategory(SR.CatData),
206.
SRDescription(SR.BindingNavigatorBindingSourcePropDescr),
207.
TypeConverter(typeof(ReferenceConverter)),
208.
SuppressMessage(
"Microsoft.Usage"
,
"CA2227:CollectionPropertiesShouldBeReadOnly"
)
209.
]
210.
public BindingSource BindingSource {
211.
get {
212.
return bindingSource;
213.
}
214.
215.
set {
216.
WireUpBindingSource(ref bindingSource, value);
217.
}
218.
}
219.
220.
[
221.
TypeConverter(typeof(ReferenceConverter)),
222.
SRCategory(SR.CatItems),
223.
SRDescription(SR.BindingNavigatorMoveFirstItemPropDescr)
224.
]
225.
public ToolStripItem MoveFirstItem {
226.
get {
227.
if (moveFirstItem != null && moveFirstItem.IsDisposed) {
228.
moveFirstItem = null;
229.
}
230.
return moveFirstItem;
231.
}
232.
233.
set {
234.
WireUpButton(ref moveFirstItem, value, new EventHandler(OnMoveFirst));
235.
}
236.
}
237.
238.
[
239.
TypeConverter(typeof(ReferenceConverter)),
240.
SRCategory(SR.CatItems),
241.
SRDescription(SR.BindingNavigatorMovePreviousItemPropDescr)
242.
]
243.
public ToolStripItem MovePreviousItem {
244.
get {
245.
246.
if (movePreviousItem != null && movePreviousItem.IsDisposed) {
247.
movePreviousItem = null;
248.
}
249.
250.
return movePreviousItem;
251.
}
252.
253.
set {
254.
WireUpButton(ref movePreviousItem, value, new EventHandler(OnMovePrevious));
255.
}
256.
}
257.
258.
[
259.
TypeConverter(typeof(ReferenceConverter)),
260.
SRCategory(SR.CatItems),
261.
SRDescription(SR.BindingNavigatorMoveNextItemPropDescr)
262.
]
263.
public ToolStripItem MoveNextItem {
264.
get {
265.
if (moveNextItem != null && moveNextItem.IsDisposed) {
266.
moveNextItem = null;
267.
}
268.
return moveNextItem;
269.
}
270.
271.
set {
272.
WireUpButton(ref moveNextItem, value, new EventHandler(OnMoveNext));
273.
}
274.
}
275.
276.
[
277.
TypeConverter(typeof(ReferenceConverter)),
278.
SRCategory(SR.CatItems),
279.
SRDescription(SR.BindingNavigatorMoveLastItemPropDescr)
280.
]
281.
public ToolStripItem MoveLastItem {
282.
get {
283.
if (moveLastItem != null && moveLastItem.IsDisposed) {
284.
moveLastItem = null;
285.
}
286.
return moveLastItem;
287.
}
288.
289.
set {
290.
WireUpButton(ref moveLastItem, value, new EventHandler(OnMoveLast));
291.
}
292.
}
293.
294.
[
295.
TypeConverter(typeof(ReferenceConverter)),
296.
SRCategory(SR.CatItems),
297.
SRDescription(SR.BindingNavigatorAddNewItemPropDescr)
298.
]
299.
public ToolStripItem AddNewItem {
300.
get {
301.
if (addNewItem != null && addNewItem.IsDisposed) {
302.
addNewItem = null;
303.
}
304.
return addNewItem;
305.
}
306.
307.
set {
308.
if (addNewItem != value && value != null) {
309.
value.InternalEnabledChanged += new System.EventHandler(OnAddNewItemEnabledChanged);
310.
addNewItemUserEnabled = value.Enabled;
311.
}
312.
WireUpButton(ref addNewItem, value, new EventHandler(OnAddNew));
313.
}
314.
}
315.
316.
[
317.
TypeConverter(typeof(ReferenceConverter)),
318.
SRCategory(SR.CatItems),
319.
SRDescription(SR.BindingNavigatorDeleteItemPropDescr)
320.
]
321.
public ToolStripItem DeleteItem {
322.
get {
323.
if (deleteItem != null && deleteItem.IsDisposed) {
324.
deleteItem = null;
325.
}
326.
return deleteItem;
327.
}
328.
329.
set {
330.
if (deleteItem != value && value != null) {
331.
value.InternalEnabledChanged += new System.EventHandler(OnDeleteItemEnabledChanged);
332.
deleteItemUserEnabled = value.Enabled;
333.
}
334.
WireUpButton(ref deleteItem, value, new EventHandler(OnDelete));
335.
336.
}
337.
}
338.
339.
[
340.
TypeConverter(typeof(ReferenceConverter)),
341.
SRCategory(SR.CatItems),
342.
SRDescription(SR.BindingNavigatorPositionItemPropDescr)
343.
]
344.
public ToolStripItem PositionItem {
345.
get {
346.
if (positionItem != null && positionItem.IsDisposed) {
347.
positionItem = null;
348.
}
349.
return positionItem;
350.
}
351.
352.
set {
353.
WireUpTextBox(ref positionItem, value, new KeyEventHandler(OnPositionKey), new EventHandler(OnPositionLostFocus));
354.
}
355.
}
356.
357.
[
358.
TypeConverter(typeof(ReferenceConverter)),
359.
SRCategory(SR.CatItems),
360.
SRDescription(SR.BindingNavigatorCountItemPropDescr)
361.
]
362.
public ToolStripItem CountItem {
363.
get {
364.
if (countItem != null && countItem.IsDisposed) {
365.
countItem = null;
366.
}
367.
return countItem;
368.
}
369.
370.
set {
371.
WireUpLabel(ref countItem, value);
372.
}
373.
}
374.
375.
[
376.
SRCategory(SR.CatAppearance),
377.
SRDescription(SR.BindingNavigatorCountItemFormatPropDescr)
378.
]
379.
public
String
CountItemFormat {
380.
get {
381.
return countItemFormat;
382.
}
383.
384.
set {
385.
if (countItemFormat != value) {
386.
countItemFormat = value;
387.
RefreshItemsInternal();
388.
}
389.
}
390.
}
391.
392.
[
393.
SRCategory(SR.CatBehavior),
394.
SRDescription(SR.BindingNavigatorRefreshItemsEventDescr)
395.
]
396.
public event EventHandler RefreshItems {
397.
add {
398.
onRefreshItems += value;
399.
}
400.
remove {
401.
onRefreshItems -= value;
402.
}
403.
}
404.
405.
[EditorBrowsable(EditorBrowsableState.Advanced)]
406.
protected virtual void RefreshItemsCore() {
407.
int count, position;
408.
bool allowNew, allowRemove;
409.
410.
//
Get
state info from the binding source (if any)
411.
if (bindingSource == null) {
412.
count = 0;
413.
position = 0;
414.
allowNew = false;
415.
allowRemove = false;
416.
}
417.
else {
418.
count = bindingSource.Count;
419.
position = bindingSource.Position + 1;
420.
allowNew = (bindingSource as IBindingList).AllowNew;
421.
allowRemove = (bindingSource as IBindingList).AllowRemove;
422.
}
423.
424.
// Enable or disable items (except when in design mode)
425.
if (!DesignMode) {
426.
if (MoveFirstItem != null) moveFirstItem.Enabled = (position > 1);
427.
if (MovePreviousItem != null) movePreviousItem.Enabled = (position > 1);
428.
if (MoveNextItem != null) moveNextItem.Enabled = (position < count);
429.
if (MoveLastItem != null) moveLastItem.Enabled = (position < count);
430.
431.
if (AddNewItem != null) {
432.
System.EventHandler handler = new System.EventHandler(OnAddNewItemEnabledChanged);
433.
addNewItem.InternalEnabledChanged -= handler;
434.
addNewItem.Enabled = (addNewItemUserEnabled && allowNew);
435.
addNewItem.InternalEnabledChanged += handler;
436.
}
437.
438.
if (DeleteItem != null) {
439.
System.EventHandler handler = new System.EventHandler(OnDeleteItemEnabledChanged);
440.
deleteItem.InternalEnabledChanged -= handler;
441.
deleteItem.Enabled = (deleteItemUserEnabled && allowRemove && count > 0);
442.
deleteItem.InternalEnabledChanged += handler;
443.
}
444.
445.
if (PositionItem != null) positionItem.Enabled = (position > 0 && count > 0);
446.
if (CountItem != null) countItem.Enabled = (count > 0);
447.
}
448.
449.
// Update current position indicator
450.
if (positionItem != null) {
451.
positionItem.Text = position.ToString(CultureInfo.CurrentCulture);
452.
}
453.
454.
// Update record count indicator
455.
if (countItem != null) {
456.
countItem.Text = DesignMode ? CountItemFormat :
String
.Format(CultureInfo.CurrentCulture, CountItemFormat, count);
457.
}
458.
}
459.
460.
protected virtual void OnRefreshItems() {
461.
// Refresh all the standard items
462.
RefreshItemsCore();
463.
464.
// Raise the public event
465.
if (onRefreshItems != null) {
466.
onRefreshItems(this, EventArgs.Empty);
467.
}
468.
}
469.
470.
public bool Validate() {
471.
bool validatedControlAllowsFocusChange;
472.
return this.ValidateActiveControl(out validatedControlAllowsFocusChange);
473.
}
474.
475.
private void AcceptNewPosition() {
476.
//
If
no position item or binding source, do nothing
477.
if (positionItem == null || bindingSource == null) {
478.
return;
479.
}
480.
481.
//
Default
to old position, in case new position turns out to be garbage
482.
int newPosition = bindingSource.Position;
483.
484.
try {
485.
// Read new position from item text (and subtract one!)
486.
newPosition = Convert.ToInt32(positionItem.Text, CultureInfo.CurrentCulture) - 1;
487.
}
488.
catch (System.FormatException) {
489.
// Ignore bad user input
490.
}
491.
catch (System.OverflowException) {
492.
// Ignore bad user input
493.
}
494.
495.
if (newPosition != bindingSource.Position) {
496.
bindingSource.Position = newPosition;
497.
}
498.
499.
RefreshItemsInternal();
500.
}
501.
502.
private void CancelNewPosition() {
503.
RefreshItemsInternal();
504.
}
505.
506.
private void OnMoveFirst(object sender, EventArgs e) {
507.
if (Validate()) {
508.
if (bindingSource != null) {
509.
bindingSource.MoveFirst();
510.
RefreshItemsInternal();
511.
}
512.
}
513.
}
514.
515.
private void OnMovePrevious(object sender, EventArgs e) {
516.
if (Validate()) {
517.
if (bindingSource != null) {
518.
bindingSource.MovePrevious();
519.
RefreshItemsInternal();
520.
}
521.
}
522.
}
523.
524.
private void OnMoveNext(object sender, EventArgs e) {
525.
if (Validate()) {
526.
if (bindingSource != null) {
527.
bindingSource.MoveNext();
528.
RefreshItemsInternal();
529.
}
530.
}
531.
}
532.
533.
private void OnMoveLast(object sender, EventArgs e) {
534.
if (Validate()) {
535.
if (bindingSource != null) {
536.
bindingSource.MoveLast();
537.
RefreshItemsInternal();
538.
}
539.
}
540.
}
541.
542.
private void OnAddNew(object sender, EventArgs e) {
543.
if (Validate()) {
544.
if (bindingSource != null) {
545.
bindingSource.AddNew();
546.
RefreshItemsInternal();
547.
}
548.
}
549.
}
550.
551.
private void OnDelete(object sender, EventArgs e) {
552.
if (Validate()) {
553.
if (bindingSource != null) {
554.
bindingSource.RemoveCurrent();
555.
RefreshItemsInternal();
556.
}
557.
}
558.
}
559.
560.
private void OnPositionKey(object sender, KeyEventArgs e) {
561.
switch (e.KeyCode) {
562.
case Keys.Enter:
563.
AcceptNewPosition();
564.
break;
565.
case Keys.Escape:
566.
CancelNewPosition();
567.
break;
568.
}
569.
}
570.
571.
private void OnPositionLostFocus(object sender, EventArgs e) {
572.
AcceptNewPosition();
573.
}
574.
575.
private void OnBindingSourceStateChanged(object sender, EventArgs e) {
576.
RefreshItemsInternal();
577.
}
578.
579.
private void OnBindingSourceListChanged(object sender, ListChangedEventArgs e) {
580.
RefreshItemsInternal();
581.
}
582.
583.
private void RefreshItemsInternal() {
584.
// Block all updates during initialization
585.
if (initializing) {
586.
return;
587.
}
588.
589.
//
Call
method that updates the items (overridable)
590.
OnRefreshItems();
591.
}
592.
593.
private void ResetCountItemFormat() {
594.
countItemFormat = SR.GetString(SR.BindingNavigatorCountItemFormat);
595.
}
596.
597.
private bool ShouldSerializeCountItemFormat() {
598.
return countItemFormat != SR.GetString(SR.BindingNavigatorCountItemFormat);
599.
}
600.
601.
private void OnAddNewItemEnabledChanged(object sender, EventArgs e) {
602.
if (AddNewItem != null) {
603.
addNewItemUserEnabled = addNewItem.Enabled;
604.
}
605.
}
606.
607.
private void OnDeleteItemEnabledChanged(object sender, EventArgs e) {
608.
if (DeleteItem != null) {
609.
deleteItemUserEnabled = deleteItem.Enabled;
610.
}
611.
}
612.
613.
private void WireUpButton(ref ToolStripItem oldButton, ToolStripItem newButton, EventHandler clickHandler) {
614.
if (oldButton == newButton) {
615.
return;
616.
}
617.
618.
if (oldButton != null) {
619.
oldButton.Click -= clickHandler;
620.
}
621.
622.
if (newButton != null) {
623.
newButton.Click += clickHandler;
624.
}
625.
626.
oldButton = newButton;
627.
RefreshItemsInternal();
628.
}
629.
630.
private void WireUpTextBox(ref ToolStripItem oldTextBox, ToolStripItem newTextBox, KeyEventHandler keyUpHandler, EventHandler lostFocusHandler) {
631.
if (oldTextBox != newTextBox) {
632.
ToolStripControlHost oldCtrl = oldTextBox as ToolStripControlHost;
633.
ToolStripControlHost newCtrl = newTextBox as ToolStripControlHost;
634.
635.
if (oldCtrl != null) {
636.
oldCtrl.KeyUp -= keyUpHandler;
637.
oldCtrl.LostFocus -= lostFocusHandler;
638.
}
639.
640.
if (newCtrl != null) {
641.
newCtrl.KeyUp += keyUpHandler;
642.
newCtrl.LostFocus += lostFocusHandler;
643.
}
644.
645.
oldTextBox = newTextBox;
646.
RefreshItemsInternal();
647.
}
648.
}
649.
650.
private void WireUpLabel(ref ToolStripItem oldLabel, ToolStripItem newLabel) {
651.
if (oldLabel != newLabel) {
652.
oldLabel = newLabel;
653.
RefreshItemsInternal();
654.
}
655.
}
656.
657.
private void WireUpBindingSource(ref BindingSource oldBindingSource, BindingSource newBindingSource) {
658.
if (oldBindingSource != newBindingSource) {
659.
if (oldBindingSource != null) {
660.
oldBindingSource.PositionChanged -= new EventHandler(OnBindingSourceStateChanged);
661.
oldBindingSource.CurrentChanged -= new EventHandler(OnBindingSourceStateChanged);
662.
oldBindingSource.CurrentItemChanged -= new EventHandler(OnBindingSourceStateChanged);
663.
oldBindingSource.DataSourceChanged -= new EventHandler(OnBindingSourceStateChanged);
664.
oldBindingSource.DataMemberChanged -= new EventHandler(OnBindingSourceStateChanged);
665.
oldBindingSource.ListChanged -= new ListChangedEventHandler(OnBindingSourceListChanged);
666.
}
667.
668.
if (newBindingSource != null) {
669.
newBindingSource.PositionChanged += new EventHandler(OnBindingSourceStateChanged);
670.
newBindingSource.CurrentChanged += new EventHandler(OnBindingSourceStateChanged);
671.
newBindingSource.CurrentItemChanged += new EventHandler(OnBindingSourceStateChanged);
672.
newBindingSource.DataSourceChanged += new EventHandler(OnBindingSourceStateChanged);
673.
newBindingSource.DataMemberChanged += new EventHandler(OnBindingSourceStateChanged);
674.
newBindingSource.ListChanged += new ListChangedEventHandler(OnBindingSourceListChanged);
675.
}
676.
677.
oldBindingSource = newBindingSource;
678.
RefreshItemsInternal();
679.
}
680.
}
681.
682.
}
683.
684.
}