Re: DataGrid [Attribute] ???
From: Manohar Kamath (mkamath_at_TAKETHISOUTkamath.com)
Date: 12/24/04
- Previous message: Arun: "Databinding composite objects"
- Next in thread: Bret Pehrson: "Re: DataGrid [Attribute] ???"
- Reply: Bret Pehrson: "Re: DataGrid [Attribute] ???"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 24 Dec 2004 02:30:25 -0600
Why not use a DataGridTableStyle?
--
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
- Previous message: Arun: "Databinding composite objects"
- Next in thread: Bret Pehrson: "Re: DataGrid [Attribute] ???"
- Reply: Bret Pehrson: "Re: DataGrid [Attribute] ???"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
Loading