Пример #1
0
        private void FindButton_Click(object sender, EventArgs e)
        {
            //changes mouse curser style
            Cursor.Current = Cursors.WaitCursor;



            using (FakeBookV3DataSetTableAdapters.UserProfilesTableAdapter profilesTableAdapter = new FakeBookV3DataSetTableAdapters.UserProfilesTableAdapter())
            {
                // Connects database to project and then Fill() to TableAdapter
                FakeBookV3DataSet fakebookDB = new FakeBookV3DataSet();
                profilesTableAdapter.Fill(fakebookDB.UserProfiles);



                // appends datarows from Table Adapter into List view
                foreach (DataRow row in fakebookDB.UserProfiles.Rows)
                {
                    // adds Labeled Rows/ Columns to list

                    ListViewItem item = new ListViewItem(row["First Name"].ToString());
                    item.SubItems.Add(row["Last Name"].ToString());
                    item.SubItems.Add(row["Company"].ToString());
                    item.SubItems.Add(row["Address"].ToString());
                    item.SubItems.Add(row["State/District"].ToString());
                    item.SubItems.Add(row["County/Province"].ToString());
                    item.SubItems.Add(row["Country"].ToString());
                    item.SubItems.Add(row["Zip/Postal"].ToString());
                    item.SubItems.Add(row["Phone1"].ToString());
                    item.SubItems.Add(row["Email"].ToString());
                    item.SubItems.Add(row["Website"].ToString());
                    lvFriends.Items.Add(item);
                }


                lvFriends.View = View.List;
            }
        }
Пример #2
0
        private void FindButton_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            /*
             * Test Code
             *
             * using (FakeBookV2DataSetTableAdapters.UserProfilesTableAdapter profilesTableAdapter = new FakeBookV2DataSetTableAdapters.UserProfilesTableAdapter())
             * {
             *  FakeBookV2DataSet db = new FakeBookV2DataSet();
             *  profilesTableAdapter.Fill(db.UserProfiles);
             *  List<> list = db.UserProfiles.ToList();
             *  foreach(use)
             *
             * }
             */


            {
                /*Test Code
                 *
                 * public int getCount() {
                 *  if (mList != null) {
                 *      return
                 *           Math.min(mList.size()), YOU_MAX_VALUE);
                 *                     } else
                 *                            {
                 *                        return 0;
                 *                                       }
                 *                              }
                 */
                using (FakeBookV3DataSetTableAdapters.UserProfilesTableAdapter profilesTableAdapter = new FakeBookV3DataSetTableAdapters.UserProfilesTableAdapter())
                {
                    FakeBookV3DataSet fakebookDB = new FakeBookV3DataSet();
                    profilesTableAdapter.Fill(fakebookDB.UserProfiles);



                    foreach (DataRow row in fakebookDB.UserProfiles.Rows)
                    {
                        /* Test Code
                         * foreach (DataRow row in dt.Rows)
                         * {
                         * //Add Item to ListView.
                         * ListViewItem item = new ListViewItem(row["Name"].ToString());
                         * item.SubItems.Add(row["CustomerId"].ToString());
                         * TestView.Items.Add(item);
                         * } */


                        ListViewItem item = new ListViewItem(row["First Name"].ToString());
                        item.SubItems.Add(row["Last Name"].ToString());
                        item.SubItems.Add(row["Company"].ToString());
                        //Test Code
                        //
                        //TestView.Items.Add(row["First Name"].ToString);
                        //TestView.Items(TestView.Items.Count-1).SubItems.Add(row["Last Name"].ToString());
                        //TestView.Items(TestView.Items.Count - 1).SubItems.Add(row["Last Name"].ToString());
                        //TestView.Items(TestView.Items.Count - 1).SubItems.Add(row["Last Name"].ToString());
                        item.SubItems.Add(row["Address"].ToString());
                        item.SubItems.Add(row["State/District"].ToString());
                        item.SubItems.Add(row["County/Province"].ToString());
                        item.SubItems.Add(row["Country"].ToString());
                        item.SubItems.Add(row["Zip/Postal"].ToString());
                        item.SubItems.Add(row["Phone1"].ToString());
                        item.SubItems.Add(row["Email"].ToString());
                        item.SubItems.Add(row["Website"].ToString());
                        lvFriends.Items.Add(item);
                    }


                    lvFriends.View = View.List;
                }
            }
        }