I have an list of objects (PrintJob) that I bind to a DataGridView. Here is a cut down version of the PrintJob object (Don't want to bore you completely!!):
public class PrintJob
{
private long pagesToPrint;
public long PagesToPrint
{
get { return pagesToPrint; }
}
private long recipientRef;
public long RecipientRef
{
get { return recipientRef; }
set { recipientRef = value; }
}
}
and I make a list of these objects and bind to the dataGridView like so:
dataGridView1.DataSource = uiModel.GetPrintJobs();
all good so far?
Everything displays fine expcept the Column Headers - which show the exact same as the Propery name in my object i.e. "PagesToPrint" appears in column header, where ideally, I would want it to display "Pages To Print" in the header text.
How do I get the Column Header text to show something a bit more readable - I guess based on the property name.
Cheers.
[DisplayName("Pages to print")]
public long PagesToPrint {...}
etc (with using System.ComponentModel;
at the top of the code file)
Yes you can use the designer with a bound data source. Just set the "DataPropertyName" property value of each column in the designer.
For example...for column 1 the "DataPropertyName" property value would be "PagesToPrint", whilst the "HeaderText" property would be the actual text ("Pages to Print"?) you want displayed as the column header.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With