R
RP
I have three grids on my Form namely, grid1, grid2 and grid3. grid3 is
readonly and is only to display result. Each grid has identical
columns i.e., Date and Amount. grid1 and grid2 can have n number of
rows depending upon user-entry. I need to combine entries in grid1 and
grid2 in a place where they can be sorted on date. since both grid1
and grid2 have identical columns.
At present I used DataSet and DataTable to collect the rows and sorted
with DataView. The DataTable contains three columns, Date, Amount and
GridName. Assume following data in the DataTable:
Date Amount GridType
---------- --------------- ------------------
2/apr/07 100 grid1
4/apr/07 200 grid2
5/apr/07 150 grid1
These dates and amounts are collectively used in a calculation
forumula to fill grid3, which too has identical columns. But grid3
will display dates in sorted (ascending) order.
Everything worked with DataTable, but I want to use Structure and
Indexer and try this out. I wrote a small code, but it is giving error
in the indexer:
========[CODE SAMPLE]=======================
//Structure
struct Capital
{
DateTime GDate;
double GAmount;
string GridType;
}
//Indexer
public int this[DateTime cellDate]
{
get
{
return (capital[cellDate]);
}
set
{
Capital[cellDate] = value;
}
}
============================================
Is it possible to sort a structure on date field. i.e, GDate in the
structure?
readonly and is only to display result. Each grid has identical
columns i.e., Date and Amount. grid1 and grid2 can have n number of
rows depending upon user-entry. I need to combine entries in grid1 and
grid2 in a place where they can be sorted on date. since both grid1
and grid2 have identical columns.
At present I used DataSet and DataTable to collect the rows and sorted
with DataView. The DataTable contains three columns, Date, Amount and
GridName. Assume following data in the DataTable:
Date Amount GridType
---------- --------------- ------------------
2/apr/07 100 grid1
4/apr/07 200 grid2
5/apr/07 150 grid1
These dates and amounts are collectively used in a calculation
forumula to fill grid3, which too has identical columns. But grid3
will display dates in sorted (ascending) order.
Everything worked with DataTable, but I want to use Structure and
Indexer and try this out. I wrote a small code, but it is giving error
in the indexer:
========[CODE SAMPLE]=======================
//Structure
struct Capital
{
DateTime GDate;
double GAmount;
string GridType;
}
//Indexer
public int this[DateTime cellDate]
{
get
{
return (capital[cellDate]);
}
set
{
Capital[cellDate] = value;
}
}
============================================
Is it possible to sort a structure on date field. i.e, GDate in the
structure?