Guys I managed to solve my problem the following way as being just below, I know it got a little gambiara :(
If anyone has any better suggestions I’d appreciate it!
private void alimentaGrid()
{
DataGridViewListaMesa.Rows.Clear();
DataSet ds = Engebuilder.Library.LDataAccess.GetDataSet("SELECT FICCOD FROM FICHA");
int contador = 0;
int aux = 0;
int QtdTotal = ds.Tables[0].Rows.Count;
int resto = QtdTotal;
ArrayList ListaMesa = new ArrayList();
foreach (DataRow row in ds.Tables[0].Rows)
{
Int64 codigo = Int64.Parse(row["FICCOD"].ToString().Trim());
ListaMesa.Add(codigo);
contador += 1;
if (resto >= 10)
{
if (contador.Equals(10))
{
string Column1 = String.Empty;
string Column2 = String.Empty;
string Column3 = String.Empty;
string Column4 = String.Empty;
string Column5 = String.Empty;
string Column6 = String.Empty;
string Column7 = String.Empty;
string Column8 = String.Empty;
string Column9 = String.Empty;
string Column10 = String.Empty;
for (int i = 0; i < ListaMesa.Count; i++)
{
Column1 = ListaMesa[0].ToString().Trim();
Column2 = ListaMesa[1].ToString().Trim();
Column3 = ListaMesa[2].ToString().Trim();
Column4 = ListaMesa[3].ToString().Trim();
Column5 = ListaMesa[4].ToString().Trim();
Column6 = ListaMesa[5].ToString().Trim();
Column7 = ListaMesa[6].ToString().Trim();
Column8 = ListaMesa[7].ToString().Trim();
Column9 = ListaMesa[8].ToString().Trim();
Column10 = ListaMesa[9].ToString().Trim();
}
DataGridViewListaMesa.Rows.Add(Column1, Column2, Column3, Column4, Column5, Column6, Column7, Column8, Column9, Column10);
ListaMesa.Clear();
contador = 0;
aux += 1;
resto = (QtdTotal - (10 * aux));
}
}
else
{
switch (resto)
{
case 9:
if (contador.Equals(9))
{
string Column1 = String.Empty;
string Column2 = String.Empty;
string Column3 = String.Empty;
string Column4 = String.Empty;
string Column5 = String.Empty;
string Column6 = String.Empty;
string Column7 = String.Empty;
string Column8 = String.Empty;
string Column9 = String.Empty;
for (int i = 0; i < ListaMesa.Count; i++)
{
Column1 = ListaMesa[0].ToString().Trim();
Column2 = ListaMesa[1].ToString().Trim();
Column3 = ListaMesa[2].ToString().Trim();
Column4 = ListaMesa[3].ToString().Trim();
Column5 = ListaMesa[4].ToString().Trim();
Column6 = ListaMesa[5].ToString().Trim();
Column7 = ListaMesa[6].ToString().Trim();
Column8 = ListaMesa[7].ToString().Trim();
Column9 = ListaMesa[8].ToString().Trim();
}
DataGridViewListaMesa.Rows.Add(Column1, Column2, Column3, Column4, Column5, Column6, Column7, Column8, Column9);
ListaMesa.Clear();
contador = 0;
resto = (resto - 9);
}
break;
case 8:
if (contador.Equals(8))
{
string Column1 = String.Empty;
string Column2 = String.Empty;
string Column3 = String.Empty;
string Column4 = String.Empty;
string Column5 = String.Empty;
string Column6 = String.Empty;
string Column7 = String.Empty;
string Column8 = String.Empty;
for (int i = 0; i < ListaMesa.Count; i++)
{
Column1 = ListaMesa[0].ToString().Trim();
Column2 = ListaMesa[1].ToString().Trim();
Column3 = ListaMesa[2].ToString().Trim();
Column4 = ListaMesa[3].ToString().Trim();
Column5 = ListaMesa[4].ToString().Trim();
Column6 = ListaMesa[5].ToString().Trim();
Column7 = ListaMesa[6].ToString().Trim();
Column8 = ListaMesa[7].ToString().Trim();
}
DataGridViewListaMesa.Rows.Add(Column1, Column2, Column3, Column4, Column5, Column6, Column7, Column8);
ListaMesa.Clear();
contador = 0;
resto = (resto - 8);
}
break;
case 7:
if (contador.Equals(7))
{
string Column1 = String.Empty;
string Column2 = String.Empty;
string Column3 = String.Empty;
string Column4 = String.Empty;
string Column5 = String.Empty;
string Column6 = String.Empty;
string Column7 = String.Empty;
for (int i = 0; i < ListaMesa.Count; i++)
{
Column1 = ListaMesa[0].ToString().Trim();
Column2 = ListaMesa[1].ToString().Trim();
Column3 = ListaMesa[2].ToString().Trim();
Column4 = ListaMesa[3].ToString().Trim();
Column5 = ListaMesa[4].ToString().Trim();
Column6 = ListaMesa[5].ToString().Trim();
Column7 = ListaMesa[6].ToString().Trim();
}
DataGridViewListaMesa.Rows.Add(Column1, Column2, Column3, Column4, Column5, Column6, Column7);
ListaMesa.Clear();
contador = 0;
resto = (resto - 7);
}
break;
case 6:
if (contador.Equals(6))
{
string Column1 = String.Empty;
string Column2 = String.Empty;
string Column3 = String.Empty;
string Column4 = String.Empty;
string Column5 = String.Empty;
string Column6 = String.Empty;
for (int i = 0; i < ListaMesa.Count; i++)
{
Column1 = ListaMesa[0].ToString().Trim();
Column2 = ListaMesa[1].ToString().Trim();
Column3 = ListaMesa[2].ToString().Trim();
Column4 = ListaMesa[3].ToString().Trim();
Column5 = ListaMesa[4].ToString().Trim();
Column6 = ListaMesa[5].ToString().Trim();
}
DataGridViewListaMesa.Rows.Add(Column1, Column2, Column3, Column4, Column5, Column6);
ListaMesa.Clear();
contador = 0;
resto = (resto - 6);
}
break;
case 5:
if (contador.Equals(5))
{
string Column1 = String.Empty;
string Column2 = String.Empty;
string Column3 = String.Empty;
string Column4 = String.Empty;
string Column5 = String.Empty;
for (int i = 0; i < ListaMesa.Count; i++)
{
Column1 = ListaMesa[0].ToString().Trim();
Column2 = ListaMesa[1].ToString().Trim();
Column3 = ListaMesa[2].ToString().Trim();
Column4 = ListaMesa[3].ToString().Trim();
Column5 = ListaMesa[4].ToString().Trim();
}
DataGridViewListaMesa.Rows.Add(Column1, Column2, Column3, Column4, Column5);
ListaMesa.Clear();
contador = 0;
resto = (resto - 5);
}
break;
case 4:
if (contador.Equals(4))
{
string Column1 = String.Empty;
string Column2 = String.Empty;
string Column3 = String.Empty;
string Column4 = String.Empty;
for (int i = 0; i < ListaMesa.Count; i++)
{
Column1 = ListaMesa[0].ToString().Trim();
Column2 = ListaMesa[1].ToString().Trim();
Column3 = ListaMesa[2].ToString().Trim();
Column4 = ListaMesa[3].ToString().Trim();
}
DataGridViewListaMesa.Rows.Add(Column1, Column2, Column3, Column4);
ListaMesa.Clear();
contador = 0;
resto = (resto - 4);
}
break;
case 3:
if (contador.Equals(3))
{
string Column1 = String.Empty;
string Column2 = String.Empty;
string Column3 = String.Empty;
for (int i = 0; i < ListaMesa.Count; i++)
{
Column1 = ListaMesa[0].ToString().Trim();
Column2 = ListaMesa[1].ToString().Trim();
Column3 = ListaMesa[2].ToString().Trim();
}
DataGridViewListaMesa.Rows.Add(Column1, Column2, Column3);
ListaMesa.Clear();
contador = 0;
resto = (resto - 3);
}
break;
case 2:
if (contador.Equals(2))
{
string Column1 = String.Empty;
string Column2 = String.Empty;
for (int i = 0; i < ListaMesa.Count; i++)
{
Column1 = ListaMesa[0].ToString().Trim();
Column2 = ListaMesa[1].ToString().Trim();
}
DataGridViewListaMesa.Rows.Add(Column1, Column2);
ListaMesa.Clear();
contador = 0;
resto = (resto - 2);
}
break;
case 1:
if (contador.Equals(1))
{
string Column1 = String.Empty;
for (int i = 0; i < ListaMesa.Count; i++)
{
Column1 = ListaMesa[0].ToString().Trim();
}
DataGridViewListaMesa.Rows.Add(Column1);
ListaMesa.Clear();
contador = 0;
resto = (resto - 1);
}
break;
default:
break;
}
}
}
}
You want to swap rows and columns this? I mean, turn rows (records) into columns and columns into rows?
– Jéf Bueno
It would be basically that, as being in the image the value of each column corresponds to a row in the database.
– Joaquim Caetano Teixeira
You would have an example of your ai database?
– KhaosDoctor