Solved

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

Posted on 2004-08-12
5
192 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now