Hai To All.
Private void BindListView()
{
There is a one simple function
written below.
Copy and paste the given below query
in your code, and call this function on Event where it required
Private void BindListView()
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3]
{ new DataColumn("Id"), new
DataColumn("Name"),
new DataColumn("Country") });
dt.Rows.Add(1,
"Raja Durai", "United States");
dt.Rows.Add(2,
"Raja", "United
States");
dt.Rows.Add(3, "Durai",
"India");
dt.Rows.Add(4, "S.Raja
Durai", "India");
lsvDetails.View
= View.SmallIcon;
lsvDetails.Columns.Clear();
lsvDetails.Columns.Add("users_id", 0);
lsvDetails.View
= View.Details;
lsvDetails.Columns.Add("User Name ", 150);
lsvDetails.Columns.Add("Country", 200);
lsvDetails.Items.Clear();
if
(dt == null || dt.Rows.Count == 0) ;
else
foreach (DataRow dr in
dt.Rows)
{
ListViewItem
lvItem = new ListViewItem(dr[0].ToString());
lvItem.SubItems.AddRange(new String[] {
dr[1].ToString(), dr[2].ToString});
lsvDetails.Items.Add(lvItem);
}
}
}
No comments:
Post a Comment