Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
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 Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

896 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

15 Experts available now in Live!

Get 1:1 Help Now