DataGrid orientation?

G

Guest

Hello is it possible to re-orient a DataGrid (i.e. make columns rows and vs)? That would be very helpful. Thank you.
 
A

Alvin Bruney [MVP]

the easier way is to re-orient the dataset and bind it to the grid which
gives the same effect.

here's some code to flip 4 columns:

//flip the columns with the rows
double input = 0.0;
for(int col = 0; col < ds.Tables[0].Columns.Count; col++)
{
DataRow myRow = dsTemp.Tables[0].NewRow();
myRow[4]= 0.00;
if(Double.TryParse(ds2.Tables[0].Rows[0][col].ToString(),
System.Globalization.NumberStyles.Any,
System.Globalization.NumberFormatInfo.InvariantInfo, out input))
myRow[4]= input.ToString();

myRow[3]= 0.00;
if(Double.TryParse(ds.Tables[0].Rows[0][col].ToString(),
System.Globalization.NumberStyles.Any,
System.Globalization.NumberFormatInfo.InvariantInfo, out input))
myRow[3]= input.ToString();

if(Double.TryParse((Double.Parse(myRow[3].ToString()) -
Double.Parse(myRow[4].ToString())).ToString(),
System.Globalization.NumberStyles.Any,
System.Globalization.NumberFormatInfo.InvariantInfo, out input))
myRow[2]= input.ToString();

if(ds2.Tables[0].Rows[0][col].ToString().Trim() != String.Empty)
myRow[1]= Math.Round(((Double.Parse(myRow[2].ToString()) /
Double.Parse(ds2.Tables[0].Rows[0][col].ToString())) * 100),2);

myRow[0]= ds.Tables[0].Columns[col].ColumnName;
dsTemp.Tables[0].Rows.Add(myRow);
}
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top