Using User Control popup for filter bindingSource RRS feed

  • Question

  • Hi, I have user control with checkedListBox and one button. I show this fill this popup on dataGridView1_CellDoubleClick event (i`ll post code below) on popup button click i want to use bindingSource.Filter. I tried it from this user control button_click event but it was doing nothing then make method in form where is datagridview and still nothing. So i want help how to get column name and than make method which can filter bindingSource. Please help me somebody. Using C# 3.5 WinForms

    This is user control button code:

    private void button1_Click(object sender, EventArgs e)
        OperatorsForm of = new OperatorsForm();
        var checkedvalues = checkedListBox1.CheckedItems.Cast<string>().Select(s => "'" + s + "%'").ToArray();
        string d = "LoadName LIKE " + string.Join(" or ", checkedvalues);
    This is popup code :
    private void dataGridView1_CellDoubleClick_1(object sender, DataGridViewCellEventArgs e)
        UserControl1 ucontrol = new UserControl1();
        var button = sender as DataGridView;
        HashSet<string> strings = new HashSet<string>();
        for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
        var listViewItems = strings.Select(x => new ListViewItem(x, 0)).ToArray();
        ListView listView = new ListView();
        listView.View = View.SmallIcon;
        listView.MultiSelect = false;
        int itemToShow = 18;
        var lastItemToShow = listViewItems.Take(itemToShow).Last();
        int height = lastItemToShow.Bounds.Bottom + listView.Margin.Top;
        listView.Height = height;
        var popup = new ToolStripDropDown();
        popup.AutoSize = false;
        popup.Margin = Padding.Empty;
        popup.Padding = Padding.Empty;
        ToolStripControlHost host = new ToolStripControlHost(ucontrol);
        host.Margin = Padding.Empty;
        host.Padding = Padding.Empty;
        host.AutoSize = false;
        host.Size = ucontrol.Size;
        popup.Size = ucontrol.Size;
        popup.Show(this, dataGridView1.Top, dataGridView1.Top);

    • Moved by Mike Dos Zhang Sunday, November 28, 2010 3:34 PM not belong to C# forum (From:Visual C# General)
    Tuesday, November 23, 2010 8:19 PM

All replies

  • Hi lester555,

    Welcome to MSDN Forums!


    Please create a new thread in winform forum for asking the winForm question. There're more winForm experts will give you the expert help.


    Have a nice weekend!



    [All-In-One Code Framework]

    Sample world! You will get more from this world!

    Welcome to the new world!

    Sunday, November 28, 2010 3:33 PM