Click here to Skip to main content
15,850,547 members
Home / Discussions / C#
   

C#

 
Questioncreate an application which generate table of the entered number.. Pin
rajiv kumar (abbi)25-Jan-12 0:01
rajiv kumar (abbi)25-Jan-12 0:01 
AnswerRe: create an application which generate table of the entered number.. Pin
Pete O'Hanlon25-Jan-12 0:19
subeditorPete O'Hanlon25-Jan-12 0:19 
AnswerRe: create an application which generate table of the entered number.. Pin
OriginalGriff25-Jan-12 0:40
mveOriginalGriff25-Jan-12 0:40 
AnswerRe: create an application which generate table of the entered number.. Pin
phil.o25-Jan-12 1:20
professionalphil.o25-Jan-12 1:20 
AnswerRe: create an application which generate table of the entered number.. Pin
Luc Pattyn25-Jan-12 1:45
sitebuilderLuc Pattyn25-Jan-12 1:45 
GeneralRe: create an application which generate table of the entered number.. Pin
Wayne Gaylard25-Jan-12 2:01
professionalWayne Gaylard25-Jan-12 2:01 
AnswerRe: create an application which generate table of the entered number.. Pin
Abhinav S25-Jan-12 1:47
Abhinav S25-Jan-12 1:47 
AnswerRe: create an application which generate table of the entered number.. Pin
PIEBALDconsult25-Jan-12 3:28
mvePIEBALDconsult25-Jan-12 3:28 
My son needed to create a table of some numbers for some homework this week, so I wrote a small WinForms app to do it. Here's a snippet:

private void DisplayTable()
{
    int rows = (int) this.numericUpDown1.Value ;

    System.Text.StringBuilder html = new System.Text.StringBuilder() ;

    html.AppendFormat ("<html><head><title>{0}</title></head><body><table cols='{1}' width='100%' border='1'><tr><th>Row</th>" ,
       this.textBox2.Text , this.columns.Count + 1 ) ;

    for ( int c = 0 ; c < this.columns.Count ; c++ )
    {
        html.AppendFormat ( "<th>{0}</th>" , this.columns [ c ].Item1 ) ;
    }

    html.Append ( "<th>Total</th></tr>" ) ;

    for ( int r = 1 ; r <= rows ; r++ )
    {
        html.AppendFormat ( "<tr><td>{0}</td>" , r ) ;

        int tot = 0 ;

        for ( int c = 0 ; c < this.columns.Count ; c++ )
        {
            int val = this.columns [ c ].Item2 * r ;

            html.AppendFormat ( "<td>{0}</td>" , val ) ;

            tot += val ;
        }

        html.AppendFormat ( "<td>{0}</td></tr>" , tot ) ;
    }

    html.Append ( "</table></body></html>" ) ;

    this.webBrowser1.DocumentText = html.ToString() ;
}


P.S. I also have apps that generate DataTables.

modified 25-Jan-12 11:06am.

GeneralRe: create an application which generate table of the entered number.. Pin
Richard Andrew x6425-Jan-12 4:10
professionalRichard Andrew x6425-Jan-12 4:10 
GeneralRe: create an application which generate table of the entered number.. Pin
Pete O'Hanlon25-Jan-12 4:31
subeditorPete O'Hanlon25-Jan-12 4:31 
GeneralRe: create an application which generate table of the entered number.. Pin
PIEBALDconsult25-Jan-12 6:04
mvePIEBALDconsult25-Jan-12 6:04 
GeneralRe: create an application which generate table of the entered number.. Pin
OriginalGriff25-Jan-12 7:22
mveOriginalGriff25-Jan-12 7:22 
GeneralRe: create an application which generate table of the entered number.. Pin
BillWoodruff27-Jan-12 8:26
professionalBillWoodruff27-Jan-12 8:26 
GeneralRe: create an application which generate table of the entered number.. Pin
PIEBALDconsult27-Jan-12 17:11
mvePIEBALDconsult27-Jan-12 17:11 
QuestionURL change Pin
salim_ali24-Jan-12 22:40
salim_ali24-Jan-12 22:40 
AnswerRe: URL change Pin
Richard Andrew x6425-Jan-12 4:11
professionalRichard Andrew x6425-Jan-12 4:11 
Questionc# how to find one Outlooktask with UserProperty Pin
Easygoing24-Jan-12 22:27
Easygoing24-Jan-12 22:27 
QuestionCan't change a button't text at runtime anymore?????? Pin
fiaolle24-Jan-12 10:28
fiaolle24-Jan-12 10:28 
AnswerRe: Can't change a button't text at runtime anymore?????? Pin
fjdiewornncalwe24-Jan-12 10:56
professionalfjdiewornncalwe24-Jan-12 10:56 
GeneralRe: Can't change a button't text at runtime anymore?????? Pin
fiaolle24-Jan-12 21:29
fiaolle24-Jan-12 21:29 
GeneralRe: Can't change a button't text at runtime anymore?????? Pin
lukeer24-Jan-12 22:15
lukeer24-Jan-12 22:15 
AnswerRe: Can't change a button't text at runtime anymore?????? Pin
OriginalGriff24-Jan-12 23:21
mveOriginalGriff24-Jan-12 23:21 
GeneralRe: Can't change a button't text at runtime anymore?????? Pin
fiaolle24-Jan-12 23:42
fiaolle24-Jan-12 23:42 
GeneralRe: Can't change a button't text at runtime anymore?????? Pin
OriginalGriff24-Jan-12 23:55
mveOriginalGriff24-Jan-12 23:55 
GeneralRe: Can't change a button't text at runtime anymore?????? Pin
fiaolle25-Jan-12 0:35
fiaolle25-Jan-12 0:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.