hi,
i am doing a project using C#, i do't know how to creat the table during runtime. i want to display the datas in the table in windows form.
if anybody know please send the details to me
Regards,
Karthikeyan S
hi,
i am doing a project using C#, i do't know how to creat the table during runtime. i want to display the datas in the table in windows form.
if anybody know please send the details to me
Regards,
Karthikeyan S
This thread asks how to build a runtime table in a WinForms app rather than creating a DB table. An in-memory System.Data.DataTable used as the DataSource for a DataGridView is a simple, common pattern that keeps the data structure separate from persistent storage. wanted an “ordinary table” for a Windows Form and pointed toward in-memory tables; the snippet below shows a minimal, copy-paste-ready approach plus a few practical notes.
using System;
using System.Data;
using System.Windows.Forms;
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
Load += MainForm_Load;
}
private void MainForm_Load(object sender, EventArgs e)
{
var dt = new DataTable();
dt.Columns.Add("ID", typeof(int));
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Date", typeof(DateTime));
dt.Rows.Add(1, "Alice", DateTime.Today);
dt.Rows.Add(2, "Bob", DateTime.Today.AddDays(-1));
var dgv = new DataGridView { Dock = DockStyle.Fill, AutoGenerateColumns = true };
dgv.DataSource = dt;
Controls.Add(dgv);
}
} Place this code after InitializeComponent (for example in Form_Load). When updating from background threads use Invoke/BeginInvoke. For editable but non-bound grids create DataGridViewColumn objects and call dgv.Rows.Add; for purely layout-style cells use TableLayoutPanel. For large datasets consider virtual mode or paging to avoid memory and UI lag. Official references: DataTable class and DataGridView class.
Jump to Post— LizR 171have you tried googling? theres a lot of examples for this
have you tried googling? theres a lot of examples for this
hi,
i am searched in google. but all focus to DB table creation.
i am need ordinary table creation in the windows form not in db.
Then search for datatables - they dont need a specific container the principal is exactly the same
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.