hello everyone,
i want to add table in windows form ..
i want to display data from database in table ..
i don't want to use datagridview .
help me how to ??
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Manoj BhoirRank #599 · 4K reputationPosted Jun 13, 2015, 8:35 AM EDT
SqlConnection con = new SqlConnection("connectionstring");
SqlDataAdapter ada = new SqlDataAdapter("select * from TableName", con);
DataTable dt = new DataTable();
ada.Fill(dt);
for (int i = 0; i < dt.Rows.Count; i++)
{
DataRow dr = dt.Rows[i];
ListViewItem listitem = new ListViewItem(dr["Column1"].ToString());
listitem.SubItems.Add(dr["Column2"].ToString());
listitem.SubItems.Add(dr["Column3"].ToString());
listitem.SubItems.Add(dr["Column4"].ToString());
listView1.Items.Add(listitem);
}
Jiyalal Gupta50 reputationPosted Jun 14, 2015, 2:12 AM EDT
Manoj BhoirRank #599 · 4K reputationPosted Jun 14, 2015, 3:41 AM EDT
I think yes you can hide first Selection row of your datagridview.
Here is a solution for standard windows controls in C#.
To hide the row headers you can use the property RowHeadersVisible and set it to false.
To make the row headers smaller you can use the property RowHeadersWidth.
Jiyalal Gupta50 reputationPosted Jun 14, 2015, 3:43 AM EDT
Manoj BhoirRank #599 · 4K reputationPosted Jun 14, 2015, 3:47 AM EDT