Solved

Adding a table (<table>) to a windows application

Posted on 2004-08-12
5
219 Views
Last Modified: 2010-04-15
I'm writing a program that's sort of like an event tracker.  I want a form to open that lists the days of the month, and inside the square for each day, what happens on that day.  I figure a table is the best way to do this, but html tags don't work.  At least I can't get them to work inside anything (panels, labels, etc), and there's no table in the toolbox for a windows application.
Anyone have a suggestion of how I can get a table to work?
0
Comment
Question by:TGrimace
5 Comments
 
LVL 1

Assisted Solution

by:chmohan
chmohan earned 50 total points
ID: 11786821
did you try a  datagrid?on a winform?
0
 
LVL 1

Author Comment

by:TGrimace
ID: 11786926
I played with the datagrid a bit, but couldn't get it the way I wanted it.
0
 
LVL 1

Expert Comment

by:chmohan
ID: 11787068
what was the problem there? when u have the datagrid up,was placing the events that happen that day the problem?because  that is the easiest way to do this:)
0
 
LVL 10

Assisted Solution

by:ptmcomp
ptmcomp earned 50 total points
ID: 11796594
Either use a dataGrid (there are others around than the poor one delivered with the framework) or use the Internet Explorer ActiveX Control to display HTML, if this is really what you want to do.
0
 
LVL 3

Accepted Solution

by:
bigjim2000 earned 150 total points
ID: 11818494
DataGrid's are DEFINITELY the way to go.  Much easier than trying to format a table and import it via an ActiveX control to your form.... ick ;-)

Here's a quick event demo for you I wrote:

private System.Windows.Forms.DataGrid dg;

public struct EVENT
{
      public int EventID;
      public string FriendlyMessage;
      public string Message;
}

private void button1_Click(object sender, System.EventArgs e)
{
      //Populate an array of some test data
      EVENT[] events = new EVENT[2];
      events[0].EventID = 5;
      events[0].FriendlyMessage = "event 5";
      events[0].Message = "this is an event ... yeah";
      events[1].EventID = 7;
      events[1].FriendlyMessage = "event 7";
      events[1].Message = "umm... another event";
      
      PopulateGrid(dg, events);
}

public void PopulateGrid(System.Windows.Forms.DataGrid grid, EVENT[] events)
{
      System.Data.DataTable dt = new System.Data.DataTable();
      System.Data.DataColumn colEventID = new System.Data.DataColumn("EventID");
      System.Data.DataColumn colFMessage = new System.Data.DataColumn("Friendly Message");
      System.Data.DataColumn colMessage = new System.Data.DataColumn("Message");
      dt.Columns.Add(colEventID);
      dt.Columns.Add(colFMessage);
      dt.Columns.Add(colMessage);
      System.Data.DataRow curRow;
      for(int i = 0; i < events.Length; i++)
      {
            curRow = dt.NewRow();
            curRow[colEventID] = events[i].EventID.ToString();
            curRow[colFMessage] = events[i].FriendlyMessage;
            curRow[colMessage] = events[i].Message;
            dt.Rows.Add(curRow);
      }
      grid.DataSource = dt;
}

Hope that helps.

-Eric
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Question! 4 38
how to check to see if datatable has headers or not 2 33
Input parameteres to DragOver 2 19
C# Linq - Join two objects into one 3 9
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question