Reputation: 1344
I am creating a dataGridView which gets its values from an arrayList. To retrieve the values, I have:
public DataSet(String totalCM, String totPM, String hkCM, String hkPM, String sherCM, String sherPM, String hinsCM, String hinsPM, String kassCM, String kassPM, String belleCM, String bellePM)
{
_totalCM = totalCM;
_totalPM = totPM;
_hiddenKnollsCM = hkCM;
_hiddenKnollsPM = hkPM;
_sherCM = sherCM;
_sherPM = sherPM;
_hinsdaleCM = hinsCM;
_hinsdalePM = hinsPM;
_kassonCM = kassCM;
_kassonPM = kassPM;
_belleCM = belleCM;
_bellePM = bellePM;
}
public String TotalCurrentMonth
{
get { return _totalCM; }
}
public String TotalPreviousMonth
{
get { return _totalPM; }
}
public String HiddenKnollsCurrentMonth
{
get { return _hiddenKnollsCM; }
}
public String HiddenKnollsPreviousMonth
{
get { return _hiddenKnollsPM; }
}
public String SherwoodCurrentMonth
{
get { return _sherCM; }
}
public String SherwoodPreviousMonth
{
get { return _sherPM; }
}
public String HinsdaleCurrentMonth
{
get { return _hinsdaleCM; }
}
public String HinsdalePreviousMonth
{
get { return _hinsdalePM; }
}
public String KassonCurrentMonth
{
get { return _kassonCM; }
}
public String KassonPreviousMonth
{
get { return _kassonPM; }
}
public String BelleIsleCurrentMonth
{
get { return _belleCM; ; }
}
public String BelleIslePreviousMonth
{
get { return _bellePM; }
}
}
How do I go about creating custom column headers for this, as they need to have a space? Probably a really dumb question, but could not find much information about this specific issue. I know that you can modify the properties in the collection of column names, but it just seems to create new column header names based off of the accessor methods in the code. Thanks in advance.
Upvotes: 0
Views: 1441
Reputation: 53595
Well, if you're using .NET 2+ you can use the DisplayNameAttribute Class.
Use in on your properties to specify the string used in the column headers of your DGV; otherwise the property name will be used (as you see).
And if you're using .NET 2+ you shouldn't be using an ArrayList, use a List<T>
instread.
Upvotes: 2