0

how can i use html div and css style in my c# window application? i want to show this data in an html table. Thanks in advance

while (reader.Read())
{
            string fname = (string)reader["std_name"];
            string lname = (string)reader["f_name"];
            string age = (string)reader["age"].ToString();

            MessageBox.Show(fname+", "+lname+", "+age);
}
3
  • If this is a WinForms application, you can't embed HTML or CSS directly into the interface. You could use a web browser control to render your markup. Commented May 10, 2014 at 19:16
  • 1
    which language is best for styling in C# window application as css is used in web? Commented May 10, 2014 at 19:18
  • I'm afraid I don't understand the question. If you're asking what .NET framework is best suited for using HTML and associated markup for presentation, I would say MVC or web forms. Commented May 10, 2014 at 19:21

2 Answers 2

1

i think there is no method to add css in wonfor as you can add in html. however you can add css like tags in wpf app.

Sign up to request clarification or add additional context in comments.

Comments

0

you must create a html file by your app this code create a html file and read information from access file then inject the informayino into html file:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Data;
using System.Data.OleDb;
using System.Windows.Forms;

namespace pomp_benzin
{
    class class_print
    {
        public void print_to_html_file(string str_sql,int count_field,string[] headers)
        {
            //خط زير تنها كانكشن استرينگ را ميخواند كه ميتوان ان را نيز به صورت دستي نوشت
            OleDbConnection con=new OleDbConnection(vars.con_str);
            OleDbCommand cmd=new OleDbCommand(str_sql,con);
            con.Open();
            OleDbDataReader rd=cmd.ExecuteReader();
            TextWriter tw = new StreamWriter(Application.StartupPath + "\\a.html", false, Encoding.UTF8);
            tw.WriteLine("<table dir='rtl' border='1' style='width:100%;border-style:solid'>");
            //ساخت هدر هر ستون در جدول با توجه به هدر هاي ارسال شده از طرثق آرايه
            tw.WriteLine("<tr>");
            for (int i = 0; i < headers.Length; i++)
            {
                tw.WriteLine("<td style='background-color: #CCCCCC;border-style:solid'>");
                tw.WriteLine(headers[i]);
                tw.WriteLine("</td>");
            }

            while(rd.Read())
            {
                tw.WriteLine("<tr>");
                for (int cel = 0; cel < count_field; cel++)
                {
                    tw.WriteLine("<td style='border-style:solid'>");
                    //محتويات يك فيلد از جدول مربوطه
                    tw.WriteLine(rd.GetValue(cel).ToString());
                    //محتويات يك فيلد از جدول مربوطه
                    tw.WriteLine("</td>");
                }
                tw.WriteLine("</tr>");
            }


            tw.WriteLine(" </table>");
            con.Close();
            tw.Close();
            System.Diagnostics.Process.Start(Application.StartupPath + "\\a.html");
        }
    }
}

then you must run a.html by: system.diagnostic.process.start("a.html");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.