問題は、それが にバインドするときStringCollection
、基になる型がstring
そうであるため、型から見つけた最初のプロパティを引き出してstring
表示することです。そのプロパティは長さです。
あなたができることは、独自のクラスであなたをラップし、のテキスト StringCollection
を表示するプロパティを公開することです。string
のラッパー クラスstring
:
public class MyString
{
private string _myString;
public string Text
{
get { return _myString; }
set { _myString = value; }
}
public MyString(string str)
{
_myString = str;
}
}
コードは次のようになります。
StringCollection dict = Settings.Default.MyDict;
// put your string in the wrapper
List<MyString> anotherdict = new List<MyString>();
foreach (string str in dict)
{
anotherdict.Add(new MyString(str));
}
BindingSource bs = new BindingSource();
// bind to the new wrapper class
bs.DataSource = anotherdict;
this.DGV.DataSource = bs;