private void WriteListView()
        {
            try
            {
                App_Data.POSDataSetTableAdapters.SelectItemsTableAdapter myItAd = new App_Data.POSDataSetTableAdapters.SelectItemsTableAdapter();
                App_Data.POSDataSet.SelectItemsDataTable objDT = new App_Data.POSDataSet.SelectItemsDataTable();
                myItAd.FillItemsBy(objDT);
                cmbIDs.Items.Clear();
                listView1.Items.Clear();
                cmbIDs.Items.Clear();
                string[] str = new string[objDT.Columns.Count];
                //adding Datarows as listview Grids

                foreach (DataRow objRR in objDT.Rows)
                {
                    for (int col = 0; col <= objDT.Columns.Count - 1; col++)
                    {
                        if (col == 0)
                        {
                            cmbIDs.Items.Add(objRR[col].ToString());
                            continue;
                        }

                        /* if (col == 2)
                         * {
                         *   if (objRR[2].ToString() == "1")
                         *   {
                         *       type = "Regular";
                         *       str[1] = type;
                         *
                         *
                         *   }
                         *   else if (objRR[2].ToString() == "2")
                         *   {
                         *       type = "Moderator";
                         *       str[1] = type;
                         *
                         *   }
                         *   continue;
                         * }*/

                        str[col - 1] = objRR[col].ToString();
                    }
                    ListViewItem ii;
                    ii = new ListViewItem(str);
                    listView1.Items.Add(ii);
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
예제 #2
0
        private void WriteListView()
        {
            try
            {
                App_Data.POSDataSetTableAdapters.SelectItemsTableAdapter myItAd = new App_Data.POSDataSetTableAdapters.SelectItemsTableAdapter();
                App_Data.POSDataSet.SelectItemsDataTable objDT = new App_Data.POSDataSet.SelectItemsDataTable();
                myItAd.FillItemsBy(objDT);
                cmbIDs.Items.Clear();
                listView1.Items.Clear();
                cmbIDs.Items.Clear();
                string[] str = new string[objDT.Columns.Count];
                //adding Datarows as listview Grids

                foreach (DataRow objRR in objDT.Rows)
                {

                    for (int col = 0; col <= objDT.Columns.Count - 1; col++)
                    {
                        if (col == 0)
                        {
                            cmbIDs.Items.Add(objRR[col].ToString());
                            continue;
                        }
                       /* if (col == 2)
                        {
                            if (objRR[2].ToString() == "1")
                            {
                                type = "Regular";
                                str[1] = type;

                            }
                            else if (objRR[2].ToString() == "2")
                            {
                                type = "Moderator";
                                str[1] = type;

                            }
                            continue;
                        }*/

                        str[col - 1] = objRR[col].ToString();
                    }
                    ListViewItem ii;
                    ii = new ListViewItem(str);
                    listView1.Items.Add(ii);

                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }