Click here to Skip to main content
15,905,508 members
Home / Discussions / C#
   

C#

 
QuestionVehicle detection in C# Pin
ruknil7-May-10 18:07
ruknil7-May-10 18:07 
AnswerRe: Vehicle detection in C# Pin
Abhinav S7-May-10 21:00
Abhinav S7-May-10 21:00 
AnswerRe: Vehicle detection in C# Pin
Peace ON7-May-10 22:33
Peace ON7-May-10 22:33 
GeneralRe: Vehicle detection in C# Pin
Stanciu Vlad7-May-10 22:41
Stanciu Vlad7-May-10 22:41 
GeneralRe: Vehicle detection in C# Pin
OriginalGriff7-May-10 22:46
mveOriginalGriff7-May-10 22:46 
GeneralRe: Vehicle detection in C# Pin
DeepToot8-May-10 9:28
DeepToot8-May-10 9:28 
GeneralRe: Vehicle detection in C# Pin
OriginalGriff7-May-10 22:44
mveOriginalGriff7-May-10 22:44 
AnswerRe: Vehicle detection in C# Pin
Peace ON7-May-10 22:54
Peace ON7-May-10 22:54 
GeneralRe: Vehicle detection in C# Pin
ruknil7-May-10 23:39
ruknil7-May-10 23:39 
AnswerRe: Vehicle detection in C# Pin
Peace ON7-May-10 23:41
Peace ON7-May-10 23:41 
GeneralRe: Vehicle detection in C# Pin
ruknil7-May-10 23:47
ruknil7-May-10 23:47 
GeneralRe: Vehicle detection in C# Pin
OriginalGriff7-May-10 23:50
mveOriginalGriff7-May-10 23:50 
GeneralRe: Vehicle detection in C# Pin
OriginalGriff7-May-10 23:48
mveOriginalGriff7-May-10 23:48 
GeneralRe: Vehicle detection in C# Pin
Pete O'Hanlon8-May-10 12:03
mvePete O'Hanlon8-May-10 12:03 
GeneralRe: Vehicle detection in C# Pin
#realJSOP7-May-10 23:44
professional#realJSOP7-May-10 23:44 
Questiondatagridview filtering....where to start? Pin
mprice2147-May-10 17:47
mprice2147-May-10 17:47 
AnswerRe: datagridview filtering....where to start? Pin
Abhinav S7-May-10 18:13
Abhinav S7-May-10 18:13 
AnswerRe: datagridview filtering....where to start? Pin
Pedro Covarrubias7-May-10 19:30
Pedro Covarrubias7-May-10 19:30 
AnswerRe: datagridview filtering....where to start? Pin
Stanciu Vlad7-May-10 22:52
Stanciu Vlad7-May-10 22:52 
GeneralRe: datagridview filtering....where to start? Pin
mprice21420-May-10 10:12
mprice21420-May-10 10:12 
GeneralRe: datagridview filtering....where to start? Pin
Stanciu Vlad20-May-10 10:22
Stanciu Vlad20-May-10 10:22 
GeneralRe: datagridview filtering....where to start? [modified] Pin
mprice21424-May-10 8:24
mprice21424-May-10 8:24 
I have the following and I'm having a hard time getting the second comboBox column to hook up to the filtered datasource. As you can see, there are two comboBoxColumns in the dataGridView. Am I missing something obvious here? Thanks. (Also, I have tried linking it up in primaryCB_SelectedIndexChanged, without success, which is why there isn't any code there for that)

public void Form1_Load(object sender, EventArgs e)
        {
            
            DataTable tblPrimary = dataSet1.Tables.Add("Primary");
            tblPrimary.Columns.Add("Type");
            tblPrimary.Rows.Add("Force");
            tblPrimary.Rows.Add("Torque");
            tblPrimary.Rows.Add("Pressure");
            
            DataTable tblSecondary = dataSet1.Tables.Add("Secondary");
            tblSecondary.Columns.Add("Primary_Type");
            tblSecondary.Columns.Add("Unit");
            tblSecondary.Rows.Add("Force", "lb");
            tblSecondary.Rows.Add("Force", "N");
            tblSecondary.Rows.Add("Force", "oz");
            tblSecondary.Rows.Add("Torque", "in-lb");
            tblSecondary.Rows.Add("Torque", "oz-in");
            tblSecondary.Rows.Add("Torque", "N-m");

            dataGridView1.DataSource = tblSecondary;

            DataGridViewComboBoxColumn col = new DataGridViewComboBoxColumn();
            col.DataSource = tblPrimary;
            col.ValueMember = "Type";
            dataGridView1.Columns.Add(col);

            
            DataGridViewComboBoxColumn col2 = new DataGridViewComboBoxColumn();
            col2.DataSource = tblSecondary;
            col2.ValueMember = "Unit";
            dataGridView1.Columns.Add(col2);

           
        }

        private void primaryCB_SelectedIndexChanged(object sender, EventArgs e)
        {

            if (dataGridView1.CurrentCell.ColumnIndex == 0) //allow control on only one column
            {

                ComboBox cb = sender as ComboBox;

                if (cb != null)
                {
                    Debug.WriteLine(cb.SelectedValue + "TEST");

                    BindingSource bsSecondary = new BindingSource();

                    bsSecondary.DataSource = dataSet1.Tables["tblSecondary"];
                   
                    string filter = string.Format("Primary_Type = {0}", cb.SelectedValue);

                    bsSecondary.Filter = filter;
                                      
                    Debug.WriteLine(filter);

                                    
                }
            }
        }

        private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {

            if (dataGridView1.CurrentCell.ColumnIndex == 0)  //allow control only on one column
            {
                ComboBox cb = e.Control as ComboBox;
                if (cb != null)
                {
                    cb.SelectedIndexChanged -= primaryCB_SelectedIndexChanged;
                    cb.SelectedIndexChanged += primaryCB_SelectedIndexChanged;
                }
            }

        }


modified on Monday, May 24, 2010 2:46 PM

GeneralRe: datagridview filtering....where to start? Pin
Stanciu Vlad25-May-10 21:12
Stanciu Vlad25-May-10 21:12 
GeneralRe: datagridview filtering....where to start? Pin
mprice21426-May-10 7:48
mprice21426-May-10 7:48 
GeneralRe: datagridview filtering....where to start? Pin
Stanciu Vlad26-May-10 10:05
Stanciu Vlad26-May-10 10:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.