Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6046219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:12:49+00:00 2026-05-23T07:12:49+00:00

How do I get my datatable to get the following format: England Germany Holland

  • 0

How do I get my datatable to get the following format:

             England   Germany   Holland   Spain   Germany   Russia   Japan

England         x

Germany                    x

Holland                             x

Spain                                         x

Germany                                               x

Russia                                                          x

Japan                                                                    x

I did get some answers before, but that was with another way. I actually want my datatable to be used in this. Also it would be nice if you could help me out on how to display the input on the correct coordinates.

best regards

My table

    DataTable Matrix = new DataTable();
        Matrix.TableName = "Matrix";
        Matrix.Columns.Add(new DataColumn("Ado"));
        Matrix.Columns.Add(new DataColumn("Ajax", System.Type.GetType("System.String")));
        Matrix.Columns.Add(new DataColumn("AZ", System.Type.GetType("System.String")));
        Matrix.Columns.Add(new DataColumn("FC-GR", System.Type.GetType("System.String")));
        Matrix.Columns.Add(new DataColumn("FC-TW", System.Type.GetType("System.String")));
        Matrix.Columns.Add(new DataColumn("FC-U", System.Type.GetType("System.String")));
        Matrix.Columns.Add(new DataColumn("Fey", System.Type.GetType("System.String")));
        Matrix.Columns.Add(new DataColumn("Her", System.Type.GetType("System.String")));
        Matrix.Columns.Add(new DataColumn("Nac", System.Type.GetType("System.String")));
        Matrix.Columns.Add(new DataColumn("PSV", System.Type.GetType("System.String")));
        Matrix.Columns.Add(new DataColumn("RKC", System.Type.GetType("System.String")));
        Matrix.Columns.Add(new DataColumn("ROD", System.Type.GetType("System.String")));
        Matrix.Columns.Add(new DataColumn("SC", System.Type.GetType("System.String")));
        Matrix.Columns.Add(new DataColumn("Spa", System.Type.GetType("System.String")));
        Matrix.Columns.Add(new DataColumn("Vit", System.Type.GetType("System.String")));
        Matrix.Columns.Add(new DataColumn("VVV", System.Type.GetType("System.String")));
        Matrix.Columns.Add(new DataColumn("WIL", System.Type.GetType("System.String")));




        Matrix.Rows.Add("Ado Den Haag", System.Type.GetType("System.String"));
        Matrix.Rows.Add("Ajax", System.Type.GetType("System.String"));
        Matrix.Rows.Add("AZ", System.Type.GetType("System.String"));
        Matrix.Rows.Add("FC Groningen", System.Type.GetType("System.String"));
        Matrix.Rows.Add("FC Twente", System.Type.GetType("System.String"));
        Matrix.Rows.Add("FC Utrecht", System.Type.GetType("System.String"));
        Matrix.Rows.Add("Feyenoord", System.Type.GetType("System.String"));
        Matrix.Rows.Add("Hercules Almelo", System.Type.GetType("System.String"));
        Matrix.Rows.Add("NAC Breda", System.Type.GetType("System.String"));
        Matrix.Rows.Add("PSV", System.Type.GetType("System.String"));
        Matrix.Rows.Add("RKC Waalwijk", System.Type.GetType("System.String"));
        Matrix.Rows.Add("Roda JC", System.Type.GetType("System.String"));
        Matrix.Rows.Add("SC Heerenveen", System.Type.GetType("System.String"));
        Matrix.Rows.Add("Sparta Rotterdam", System.Type.GetType("System.String"));
        Matrix.Rows.Add("Vitesse", System.Type.GetType("System.String"));
        Matrix.Rows.Add("VVV-Venlo", System.Type.GetType("System.String"));
        Matrix.Rows.Add("Willem II", System.Type.GetType("System.String"));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:12:49+00:00Added an answer on May 23, 2026 at 7:12 am

    I had a project was printing on dot matrix Printers ,i changed my code it can help you for displaying create an console project and replace the code with mine

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;
    namespace Matrix
    {
        class Program
        {
            public static System.Data.DataTable CreateTeamTable()
            {
                DataTable team = new DataTable();
                team.TableName = "Team";
    
                team.Columns.Add(new DataColumn("TeamCode", typeof(int)));
                team.Columns.Add(new DataColumn("TeamName", typeof(string)));
    
                team.Rows.Add(new object[] { 0, "Ado Den Haag" });
                team.Rows.Add(new object[] { 1, "AZ" });
                team.Rows.Add(new object[] { 2, "FC Groningen" });
                team.Rows.Add(new object[] { 3, "FC Twente" });
                team.Rows.Add(new object[] { 4, "FC Utrecht" });
                team.Rows.Add(new object[] { 5, "Feyenoord" });
                team.Rows.Add(new object[] { 6, "Hercules Almelo" });
                team.Rows.Add(new object[] { 7, "NAC Breda" });
                team.Rows.Add(new object[] { 8, "PSV" });
                team.Rows.Add(new object[] { 9, "Roda JC" });
                team.Rows.Add(new object[] { 10, "SC Heerenveen" });
                team.Rows.Add(new object[] { 11, "Sparta Rotterdam" });
                team.Rows.Add(new object[] { 12, "Vitesse" });
                team.Rows.Add(new object[] { 13, "VVV-Venlo" });
                team.Rows.Add(new object[] { 14, "Willem II" });
                return team;
            }
            public static System.Data.DataTable CreateMatchTable()
            {
                DataTable matchTable = new DataTable();
                matchTable.TableName = "Match";
                matchTable.Columns.Add(new DataColumn("Host", typeof(int)));
                matchTable.Columns.Add(new DataColumn("Guest", typeof(int)));
                matchTable.Columns.Add(new DataColumn("Date", typeof(string)));
                matchTable.Columns.Add(new DataColumn("HostScor", typeof(int)));
                matchTable.Columns.Add(new DataColumn("GuestScor", typeof(int)));
    
                return matchTable;
            }
            public static List<MatrixItem> ToMatrix(System.Data.DataTable tbl)
            {
                var result = new List<MatrixItem>();
                int i = 0;
                foreach (System.Data.DataColumn column in tbl.Columns)
                {
    
                    int j = 0;
                    int x = 0;
                    foreach (System.Data.DataRow item in tbl.Rows)
                    {
    
                        var col = item[column].ToString();
                        if (i > 0)
                            col = string.Empty;
                        if (x == 0)
                        {
                            col = column.ColumnName;
                        }
                        if ((j == i) && (i > 0))
                            col = "*";
                        var m = new MatrixItem() { ColData = col, X = x, Y = i };
                        x += 15;
                        result.Add(m);
                        j++;
                    }
                    i++;
                }
                return result;
            }
            public static List<MatrixItem> CreateSample()
            {
                var list = new List<MatrixItem>();
    
                var countries = new string[] { "          ", "England   ", "Germany   ", "Holland   ", "Spain   ", "Germany   ", "Russia   ", "Japan" };
                for (int i = 0; i < countries.Length; i++)
                {
                    int x = 0;
                    int j = 0;
                    foreach (var item in countries)
                    {
                        var col = item;
                        if (i > 0)
                            col = string.Empty;
                        if (x == 0)
                        {
                            col = countries[i];
                        }
                        if ((j == i) && (i > 0))
                            col = "*";
                        var m = new MatrixItem() { ColData = col, X = x, Y = i };
                        x += item.Length;
                        list.Add(m);
                        j++;
                    }
                }
                return list;
            }
            public static void PrintMenu(System.Data.DataTable tblTeam)
            {
                Console.Clear();
                foreach (System.Data.DataRow item in tblTeam.Rows)
                {
                    Console.WriteLine(string.Format("{0} )- {1}", item["TeamCode"], item["TeamName"]));
                }
                Console.WriteLine("Press 1 to Enter Results");
                Console.WriteLine("Press 2 to show result table");
    
                Console.WriteLine("Enter Command Number");
            }
            public static void printMatrix(List<MatrixItem> list)
            {
                var j = 0;
                DosPrinter ds = new DosPrinter(900, 18);
                foreach (var item in list)
                {
                    ds.PrintXY(item.X, item.Y, item.ColData);
                }
                ds.Finilize();
            }
            public static int Readint()
            {
                string gcstr = Console.ReadLine();
                int gc = 0;
                while (!Int32.TryParse(gcstr, out gc))
                {
                    Console.WriteLine("Bad Value ( press x to exit app) re enter code : ");
                    gcstr = Console.ReadLine();
                }
                if (gcstr.ToLower() == "x")
                    return -1;
                return gc;
            }
            public static void GetResults(System.Data.DataTable results)
            {
                Console.WriteLine();
                Console.ReadLine();
                Console.Write("Enter Guest Code: ");
                int hc = Readint();
                Console.Write("Enter HostCode Code: ");
                int gc = Readint();
                Console.Write("Enter Match date: ");
                string dateStr = Console.ReadLine();
                Console.Write("Enter host score: ");
                int hs = Readint();
                Console.Write("Enter Guestscore: ");
                int gs = Readint();
                results.Rows.Add(new object[] { hc, gc, dateStr, hs, gs });
            }
            public static void ShowResult(System.Data.DataTable tblTeam,System.Data.DataTable tblMatches)
            {
                Console.Clear();
                var matrixList = new List<MatrixItem>();
                int i = 0;
                foreach (System.Data.DataRow horzRow in tblTeam.Rows)
                {
                    int x = 0;
                    int j = 0;
                    foreach (System.Data.DataRow vertRow in tblTeam.Rows)
                    {
                        string col = string.Empty;
                        if (i > 0 & j > 0)
                        {
                            var rs = tblMatches.Select(string.Format("(Host={0} and guest={1}) or (Host={1} and guest={0})", horzRow["TeamCode"], vertRow["TeamCode"]));
                            if (rs.Length > 0)
                                col = "*";
                        }
                        if (i == 0 & j == 0)
                        {
                            col = "        ";
                        }
                        if ((i == 0) && (j > 0))
                        {
                            col = vertRow["TeamName"].ToString();
                        }
                        if ((i > 0) && (j == 0))
                        {
                            col = horzRow["TeamName"].ToString();
                        }
    
                        var m = new MatrixItem() { ColData = col, X = x, Y = i };
                        x += 25;
                        matrixList.Add(m);
                        j++;
    
                    }
                    i++;
                }
                printMatrix( matrixList );
                Console.ReadKey();
            }
    
            static void Main(string[] args)
            {
                var teams = CreateTeamTable();
                var matches = CreateMatchTable();
                int x = 'a';
                while (x != 'x')
                {
                    PrintMenu(teams);
    
                    x = Console.Read();
                    if (x == '1')
                    {
                        GetResults(matches);
                    }
                    if (x == '2')
                    {
                        ShowResult(teams, matches);
                    }
                }
    
                Console.ReadKey();
            }
        }
    
        public class MatrixItem
        {
            public string ColData { get; set; }
            public int X { get; set; }
            public int Y { get; set; }
    
        }
        public class DosPrinter
        {
            #region Fields
            private int width;
            private int height;
            private byte[,] canvas;
            private int baseX = 0;
            private int baseY = 0;
    
    
            #endregion
    
    
    
            #region Functionality
    
    
            public void PrintXY(int x, int y, string value)
            {
                int startx = baseX + x;// -value.Length;
                for (int i = 0; i < value.Length; i++)
                {
                    canvas[startx + i, baseY + y] = Convert.ToByte(value[i]);
                }
            }
            public void Finilize()
            {
                object k = 1;
                object l = 0;
                object lf = false;
                object ss = " ";
    
                try
                {
                    for (int i = 0; i < height; i++)
                    {
    
                        Array crt = Array.CreateInstance(typeof(byte), baseX + this.width);
                        string line = string.Empty;
                        for (int j = 0; j < baseX + width; j++)
                        {
                            crt.SetValue(canvas[j, i], j);
                            line += ((char)canvas[j, i]).ToString();
                        }
                        Console.WriteLine(line);
                        //vbPrinter.PrintBytes(ref crt, ref LineFeed);
                    }
                }
                catch { }
            }
            public void CleareBuffer()
            {
                InitCanvas();
            }
            public void InitCanvas()
            {
                canvas = new byte[baseX + width, baseY + height];
                for (int i = 0; i < width; i++)
                {
                    for (int j = 0; j < height; j++)
                    {
                        canvas[i, j] = 32;
                    }
                }
            }
            public string DrawLine(int len)
            {
                string line = string.Empty;
                for (int i = 0; i < len; i++)
                {
                    line += "-";
                }
                return line;
            }
            #endregion
    
            #region Constructor
            public DosPrinter(int width, int height)
            {
                this.width = baseX + width;
                this.height = baseY + height;
                InitCanvas();
            }
            #endregion
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For the following datatable column, what is the fastest way to get the min
Consider the following snippet of code: // get number of sheep in DataTable by
How to get a DataTable from DataRow[] collection ? I tried the following conversion
How to get layout like the following using h:selectOneRadio encapsulated within a rich:dataTable row1
I am attempting to get distinct values from a datatable column. here is my
When updating a DataTable with 1850-ish new rows to a FbDataAdapter I get a
How can I get the value of title1 from this string in a datatable
I get the following exception when i try to execute specific stored procedure :
The following method of course works, but after a certain number of uploads (this
I have the following datatable : id name name_in 3 sys sys 5 con

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.