TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Vuk Stanojevic
1.6k
140
45k
C# Listview one columns with two rows
Apr 12 2020 9:30 AM
Hi everyone,
Im trying to create listview with two headers.
Main header is regular one.
But line bellow should be another header but with two cells.
In "2nd" header there should be only text.
And in all other rows there should be checkboxes.
Here is the picture how it should look like.
What i have in this moment is:
private
void
comboBox1_SelectedIndexChanged(
object
sender, EventArgs e)
{
listView1.Columns.Clear();
SqlConnection con =
new
SqlConnection(@
"Data Source=MAIN-PC\SQLEXPRESS;Integrated Security=True"
);
SqlCommand cmd =
new
SqlCommand(
"USE "
+comboBox1.Text+
" ; Select * FROM stores"
,con);
DataTable dt =
new
DataTable();
con.Open();
SqlDataAdapter da =
new
SqlDataAdapter(cmd);
da.Fill(dt);
ListView view =
new
ListView();
view.View = View.Details;
//Header 1 - first column is text, other column names are equal to database values
listView1.Columns.Add(
"Store"
, 120, HorizontalAlignment.Left);
foreach
(DataRow row
in
dt.Rows)
{
listView1.Columns.Add(row[0].ToString()+
" "
+
""
+row[1].ToString()+
""
, 80, HorizontalAlignment.Left);
}
listView1.Items.Clear();
//Subheader
listView1.Items.Add(
"Status"
);
foreach
(DataRow row
in
dt.Rows)
{
}
Thank you.
Reply
Answers (
1
)
How to clear control that has children?
connecter à une base de donnée via app.config