"Bret Pehrson" <bret@classicade.com> wrote in message
news:41D07C0A.F761ADA1@classicade.com...
> Manohar Kamath wrote:
>>
>> Why not use a DataGridTableStyle?
>
> Because I want to affect the change through the class/data (domain-level
> object) rather than the grid (presentation layer).
>
> In my mind, it seems that it would be appropriate if the DataGrid control
> to
> use attributes on the data itself for some of the display characteristics.
> In
> my case, column name is a good example, as is numeric formatting, etc.
>
> Implementation of this feature would be trivial within the DataGrid, but
> obviously didn't happen as I haven't been able to locate anything on it,
> and no
> one has indicated otherwise.
>
>
>>
>> --
>> Manohar Kamath
>> Editor, .netWire
>>
www.dotnetwire.com >>
>> "Bret Pehrson" <bret@classicade.com> wrote in message
>> news:41C88A51.928DC825@classicade.com...
>> > Question/issue:
>> >
>> > I'm using a custom data source for my (WinForms) datagrid:
>> >
>> > public class MyDataSource : IList
>> > {
>> > public void AddRow(string firstName, string lastName);
>> > // ...
>> > }
>> >
>> > each row is a:
>> >
>> > public class MyDataRow
>> > {
>> > public string FirstName
>> > {
>> > get { return firstName; }
>> > }
>> > private string firstName;
>> > //...
>> > }
>> >
>> > Then:
>> >
>> > MyDataSource data = new MyDataSource();
>> > data.AddRow("Bret", "Pehrson");
>> > //...
>> >
>> > grid.DataSource = data;
>> >
>> >
>> > Now, everything displays fine in the DataGrid. I'm not using any
>> > designer
>> or
>> > other parameters to set up the columns, just letting the data source
>> > and
>> grid
>> > figure that out. The only problem that I have is that I want the
>> > DataGrid
>> to
>> > display "First name" as the column header and not "FirstName" as is
>> currently
>> > happening.
>> >
>> > What I'd hope would be possible is some attribute on the FirstName
>> property
>> > that would specify the column name, something like
>> >
>> > [HeaderText("First name")]
>> > public string FirstName
>> > {
>> > get { return firstName; }
>> > }
>> >
>> > Is there such a beast? I've looked and looked, and can't find
>> > anything.
>> I
>> > want all of this to be done in the code for the MyDataRow/MyDataSource
>> class.
>> >
>> > Thanks