The best way to refer to grid column?

  • Thread starter Thread starter Arial
  • Start date Start date
A

Arial

Hi all!

What is the best way to hold some kind of "invariant" reference to access
grid columns (any grid, not only MS grids)?

Currently I use structs, like that:
struct ColLayers{
public string Col1;
public string Col2;
public string Col3;

public Init()
{
Col1="MyName1";
Col2="MyName2";
Col3="MyName3";
}
}

later in code I do

ColLayer C=new ColLayers();
C.Init();

so I can refer to grid like this (see the intellisense)

grid.Row[0].Column[C.Col1].Value="xx";
grid.Row[0].Column[C.Col2].Value="yy";
.....

is there some shorter/smarter way to do that in C#?

I presume enums are not the option since
they require .ToString() casting.
 
Hi all!

What is the best way to hold some kind of "invariant" reference to access
grid columns (any grid, not only MS grids)?

Currently I use structs, like that:
struct ColLayers{
   public string Col1;
   public string Col2;
   public string Col3;

    public Init()
    {
    Col1="MyName1";
    Col2="MyName2";
    Col3="MyName3";
    }

}

later in code I do

ColLayer C=new ColLayers();
C.Init();

so I can refer to grid like this (see the intellisense)

grid.Row[0].Column[C.Col1].Value="xx";
grid.Row[0].Column[C.Col2].Value="yy";
....

is there some shorter/smarter way to do that in C#?

I presume enums are not the option since
they require .ToString() casting.

This seems to be overly complicated. Why do you even need an object
there - why not static fields? For that matter, why not just const
fields?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top