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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Manoj BhoirPosted Jun 13, 2015, 12:35 PM
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);
}
Manoj BhoirPosted Jun 14, 2015, 7:47 AM
Jiyalal GuptaPosted Jun 14, 2015, 7:43 AM
Manoj BhoirPosted Jun 14, 2015, 7:41 AM
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 GuptaPosted Jun 14, 2015, 6:12 AM