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
Daniel Rabinovits
NA
34
7.7k
I am trying to populate a 3 column listView.
Aug 15 2019 9:20 AM
I am trying to populate a 3 column list box. It populates the first item only into many columns.
string connStr = Properties.Settings.Default.conn;
string sql = "SELECT Comment, [User Name], EventDate FROM Notes WHERE [Project ID] = " + value + " ORDER BY EventDate DESC;";
listView1.Columns.Add("Comment", listView1.Width / 2);
listView1.Columns.Add("User Name", listView1.Width / 4);
listView1.Columns.Add("Event Date", listView1.Width / 4);
using (OleDbConnection connection = new OleDbConnection(connStr))
{
OleDbCommand command = new OleDbCommand(sql, connection);
connection.Open();
OleDbDataReader reader = command.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
ListViewItem lvi = new ListViewItem(reader[0].ToString());
for (int i = 0; i <= reader.FieldCount - 1; i++)
{
lvi.SubItems.Add(reader[i].ToString());
}
listView1.Items.Add(lvi);
}
reader.Close();
connection.Close();
}
}
Reply
Answers (
1
)
records don’t print in my program but they print in viewer
How to get the value of bootstrap dropdown ?