Visual Studio Development Bookmark and Share   
 index > Visual C# Express Edition > VC# 2008 Express WinForms application-DataSet in Database Explorer & Controls on Form1: Re-organize boxes of ComboBox for Filter & LINQ
 

VC# 2008 Express WinForms application-DataSet in Database Explorer & Controls on Form1: Re-organize boxes of ComboBox for Filter & LINQ

Hi all,

I have Visual C#2008 Express and SQL Server 2008 Express installed in my Microsoft Windows XP Pro PC that is part of Microsoft NT 4 LAN System in our office.  Recently, I picked up some skills of handling the Relational Database Management, T-SQL, etc. in SQL Server 2008 Express.  Now I am doing "Managing the Data" and "ADO.NET, Data Binding, and LINQ" in Visual C#2008 Express . I am using a book "Building a Program Now! Microsoft Visual C# 2008 Express Edition" by Patrice Pelland and following the example "CarTrack" in Chapter 8 (Managing the Data) of the book to do my first project "scCarTrack":  I followed the Steps 1-8 listed on Pages 159-160 of the book to create a Windows Application project "scCarTreck",  the Steps on Pages 161-162 to create 4 Tables (Make, CarType, Color & Listing), the Steps on Pages 163 -166 to create Relationships between Tables, and the Steps on Page 167-170 to enter Data in SQL Server Tables using Visual Studio. 

I went on to develop the scCarTrack application: I followed the Steps on Pages 174-176 of the book to create a Dataset and have the Dataset in the Data Sources window. I completed Step 10 (on Page 176): Change ColorID, MakeID, and CarTypeID to ComboBox type by clicking the drop-down arrow next to each column and selecting ComboBox. I followed the Step 11 (on Page 176): Select the Listing nodes by clicking it, and then drag it near the top-left corner of the designer surface Form1. I got the following on Form1:
                                     |<  <| 0     of (0)| >  >|   +  X  
                                     Listing ID         ColorID        MakeID
                               |>  |                 |                  |                |

                              carTrackerDataSet             ListingBindingSource
                              ListingTableAdapter            tableAdapterManager
                              ListingBindingNavigator
This result is like the result of Figure 8-19 on Page 177:
                                     |<   <|0     of (0)|  >  >|   +  X
                                      ListingID:    |                   |
                                      ColorID:     |                  v|
                                      MakeID:     |                  v|
                                      CarTypeID: |                  v|
                                      DataSeen:   | Saturday December 12, 2007    v |
                                      Year:           |                   |
                                      Price:           |                   |
                                      Cylinder:      |                    |
                                      HP:              |                    |
                                      RUL:            |                    |
                                      EPGCity:      |                    |
                                      EPGHighway  |                    |
                                      Notes:           |                    |

(1) I tried to re-organize the boxes of Combox in Figure 8-19 (shown above) in the different areas of Form1 (like Figure 8-29 on Page 190) without luck. Please help and tell me how to re-organize the existing boxes of ComboBox on the Form1 to the different areas of the Form1.
(2) I want to add 3 filters (Filter By Color, Filter By Make, and Filter By Car Type) to this project.  How can I add the 3 filters on the Form1?
(3) I want to use LINQ and add LINQ query:
         var queryResults = from cust in customers _
                                     where cust.Country = "USA"
                                     select cust.CompanyName, cust.Country;

         var filterByMake = from Listing in this.carTrackerDataSet.Listing
                                     join Make in this.carTrackerDataSet.Make
                                     on Listing.MakeID equals MakeMakeID
                                     where (MakeName.ToLower().Contains(tstbFilterByMake.Text.ToLower()))
                                     select Listing;
          this.listingBindingSource.DataSource = filterByMake;

These things are used after the following code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace scCarTrack
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void listingBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.listingBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.carTrackerDataSet);

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'carTrackerDataSet.Listing' table. You can move, or remove it, as needed.
            this.listingTableAdapter.Fill(this.carTrackerDataSet.Listing);

        }

       
        

        
    }
}


Please help and advise.

Thanks in advance,
Scott Chang
SHC
Scott Chang  Wednesday, October 07, 2009 3:34 PM
Scott,

For linq to DataSet, here are some samples and other info you may want to learn from there.

http://msdn.microsoft.com/en-us/vbasic/bb688086.aspx

http://msdn.microsoft.com/en-us/library/bb387003.aspx

John
John Chen -- See my team blog: http://blogs.msdn.com/vsdata. All my posts are provided "AS IS" with no warranties, and confer no rights.
  • Marked As Answer byScott Chang Saturday, October 10, 2009 4:25 PM
  •  
John Chen MS  Saturday, October 10, 2009 5:14 AM
Hi,

I'm afraid most of us do not own that book you are reading.
You might need to be more specific about the scenario.

What is the problem ?

Harry
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Harry Zhu  Friday, October 09, 2009 6:39 AM
Hi Harry,

The problem is: if I delete all the controls and carTrackerDataSet, listingBindingSource, ListingTableAdapter, tableAdapterManager and ListingBindingNavigator that are on the Component Tray, I do not know how to create some of original controls on the Form1 without the carTrackerDataSet, listingBindingSource, ListingTableAdapter, tableAdapterManager and ListingBindingNavigator. I also do not know how to create 3 Filters "filterByMake", "filterByCarType". and "filterByColor" on Form1 for the future use in LINQ.  Please help and advise.

Thanks,
Scott Chang  


SHC
Scott Chang  Friday, October 09, 2009 1:43 PM
Scott,

For linq to DataSet, here are some samples and other info you may want to learn from there.

http://msdn.microsoft.com/en-us/vbasic/bb688086.aspx

http://msdn.microsoft.com/en-us/library/bb387003.aspx

John
John Chen -- See my team blog: http://blogs.msdn.com/vsdata. All my posts are provided "AS IS" with no warranties, and confer no rights.
  • Marked As Answer byScott Chang Saturday, October 10, 2009 4:25 PM
  •  
John Chen MS  Saturday, October 10, 2009 5:14 AM

Hi John,

I want to do the re-organized ComboBox and the 3 filters first. Can you help and tell me how to get the new boxes of ComboBox without the things in the Component Tray?  This is the first thing I want.  Please respond.

Thanks,

Scott Chang

  

 


SHC
Scott Chang  Saturday, October 10, 2009 4:32 PM

You can use google to search for other answers

Custom Search

More Threads

• Displaying open file name in the title bar
• Does C# has an equilivalent of EXEC($command) in SQL?
• Set Dialog box control programmatically
• Best Way to Inherit from a Generic Class?
• ILDasm.exe for express edition...where to find ?
• HELP ME C# I'm new
• Video streaming in C#.Net from Youtube
• email send
• Using Passport in C# Form
• tableadapter does not bring the value back to database