2 // System.Windows.Forms.ListControl.cs
5 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
6 // Dennis Hayes (dennish@raytek.com)
7 // Brian Takita (brian.takita@runbox.com)
8 // (C) 2002/3 Ximian, Inc
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System
.Collections
;
34 using System
.ComponentModel
;
35 using System
.Reflection
;
37 namespace System
.Windows
.Forms
{
43 public abstract class ListControl
: Control
{
45 internal string DisplayMember_
= String
.Empty
;
47 internal object DataSource_
;
48 //ControlStyles controlStyles;
50 // --- Public Properties
53 public object DataSource
{
58 if (DataSource_
!= value) {
59 if ((value is IList
) || (value is IListSource
)) {
61 OnDataSourceChanged (new EventArgs ());
64 throw new Exception ("Complex DataBinding accepts as a data source either an IList or an IListSource");
70 public string DisplayMember
{
72 return DisplayMember_
;
75 if (DisplayMember_
!= value) {
76 DisplayMember_
= value;
77 OnDisplayMemberChanged(new EventArgs());
82 internal string getDisplayMemberOfObj (object obj
) {
83 string objectString
= String
.Empty
;
84 Type t
= obj
.GetType();
86 if (DisplayMember
!= String
.Empty
) {
88 PropertyInfo prop
= t
.GetProperty (DisplayMember
);
90 objectString
= prop
.GetValue (obj
, null).ToString ();
93 if (objectString
== String
.Empty
)
94 objectString
= obj
.ToString();
99 internal class ListControlComparer
: IComparer
{
100 private ListControl owner_
= null;
101 public ListControlComparer(ListControl owner
) {
106 public int Compare(object x
, object y
) {
107 return owner_
.getDisplayMemberOfObj(x
).CompareTo (owner_
.getDisplayMemberOfObj (y
));
113 public abstract int SelectedIndex {get;set;}
116 public object SelectedValue
{
118 throw new NotImplementedException ();
125 public string ValueMember
{
127 throw new NotImplementedException ();
135 // --- Public Methods
139 public string GetItemText (object item
) {
140 throw new NotImplementedException ();
147 public event EventHandler DataSourceChanged
;
149 public event EventHandler DisplayMemberChanged
;
152 // --- Protected Constructor
155 protected ListControl () {
160 // --- Protected Properties
163 protected CurrencyManager DataManager
{
165 throw new NotImplementedException ();
170 // --- Protected Methods
174 protected object FilterItemOnProperty(object item
){
175 throw new NotImplementedException ();
179 protected object FilterItemOnProperty(object item
, string field
){
180 throw new NotImplementedException ();
184 protected override bool IsInputKey (Keys keyData
) {
186 return base.IsInputKey(keyData
);
189 protected virtual void OnDataSourceChanged (EventArgs e
) {
193 protected virtual void OnDisplayMemberChanged (EventArgs e
) {
198 protected virtual void OnSelectedIndexChanged (EventArgs e
) {
203 protected virtual void OnSelectedValueChanged (EventArgs e
) {
207 public event EventHandler SelectedValueChanged
;
208 public event EventHandler ValueMemberChanged
;
211 protected override void OnBindingContextChanged (EventArgs e
) {
213 base.OnBindingContextChanged(e
);
217 protected virtual void OnValueMemberChanged (EventArgs e
) {
222 protected virtual void SetItemCore (int index
, object value) {
225 protected abstract void SetItemsCore (IList items
);
228 protected abstract void RefreshItem (int index
);