本文整理汇总了C#中Category.collection方法的典型用法代码示例。如果您正苦于以下问题:C# Category.collection方法的具体用法?C# Category.collection怎么用?C# Category.collection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Category
的用法示例。
在下文中一共展示了Category.collection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: populateCategoriesCombobox
/// <summary>
/// Populate category combobox by loading the values from the database.
/// Also append the current selection in this way.
/// </summary>
private void populateCategoriesCombobox()
{
Category categories = new Category();
DataTable results = categories.collection();
if (results != null)
{
foreach (DataRow row in results.Rows)
{
comboBoxCategory.Items.Add(new { category_id = row["category_id"].ToString(), name = row["name"].ToString()});
}
comboBoxCategory.ValueMember = "category_id";
comboBoxCategory.DisplayMember = "name";
}
}
示例2: refreshCategoriesListView
/// <summary>
/// Refresh category list view.
/// </summary>
private void refreshCategoriesListView()
{
listViewCategories.Items.Clear();
Category products = new Category();
DataTable results = products.collection();
String[] fields = new[] { "name" };
if (results != null)
{
foreach (DataRow row in results.Rows)
{
ListViewItem item = new ListViewItem(new[] { row["category_id"].ToString() });
foreach (String rowName in fields)
{
item.SubItems.Add(row[rowName].ToString());
}
listViewCategories.Items.Add(item);
}
}
else
{
listViewCategories.Items.Add(new ListViewItem(new[] { "Nu exista rezultate" }));
}
listViewCategories.View = View.Details;
}