Click here to Skip to main content
15,037,168 members
Home / Discussions / C#
   

C#

 
QuestionHow to create filtering for DataTable based on toggle switches? Pin
Alex Dunlop27-Jul-21 21:46
MemberAlex Dunlop27-Jul-21 21:46 
AnswerRe: How to create filtering for DataTable based on toggle switches? Pin
OriginalGriff27-Jul-21 21:53
mveOriginalGriff27-Jul-21 21:53 
GeneralRe: How to create filtering for DataTable based on toggle switches? Pin
Alex Dunlop27-Jul-21 22:03
MemberAlex Dunlop27-Jul-21 22:03 
GeneralRe: How to create filtering for DataTable based on toggle switches? Pin
OriginalGriff27-Jul-21 22:13
mveOriginalGriff27-Jul-21 22:13 
GeneralRe: How to create filtering for DataTable based on toggle switches? Pin
Alex Dunlop27-Jul-21 23:35
MemberAlex Dunlop27-Jul-21 23:35 
GeneralRe: How to create filtering for DataTable based on toggle switches? Pin
OriginalGriff28-Jul-21 0:47
mveOriginalGriff28-Jul-21 0:47 
GeneralRe: How to create filtering for DataTable based on toggle switches? Pin
Alex Dunlop28-Jul-21 20:11
MemberAlex Dunlop28-Jul-21 20:11 
GeneralRe: How to create filtering for DataTable based on toggle switches? Pin
OriginalGriff28-Jul-21 22:00
mveOriginalGriff28-Jul-21 22:00 
Firstly, a DataView isn't a table - it is a filtered view of a table and that's quite different in reality.

Secondly, it works fine for me:
private void TwoDGVs_Shown(object sender, EventArgs e)
    {
    string strConnect = SMDBSupport.SMInstanceStorage.GetInstanceConnectionString(DBName);
    DataTable dt = new DataTable();
    using (SqlConnection con = new SqlConnection(strConnect))
        {
        try
            {
            con.Open();
            using (SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM MyTable", con))
                {
                da.SelectCommand.Parameters.AddWithValue("@SEARCH", "The text to search for");
                da.Fill(dt);
                }
            }
        catch (Exception ex)
            {
            Debug.WriteLine(ex.ToString());
            }
        }
    DataView dv = new DataView(dt);
    Source.DataSource = dv;
    }

private void Filter_TextChanged(object sender, EventArgs e)
    {
    if (Source.DataSource is DataView dv)
        {
        dv.RowFilter = $"Title LIKE '%{Filter.Text}%'";
        DataTable dt = dv.ToTable();
        Destination.DataSource = dt;
        }
    }
I get two DGV's, one looking a all rows, the other filtered.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!

AnswerRe: How to create filtering for DataTable based on toggle switches? Pin
jsc4227-Jul-21 23:35
professionaljsc4227-Jul-21 23:35 
QuestionHow to copy DataTable contents into SQLite table? Pin
Alex Dunlop26-Jul-21 20:37
MemberAlex Dunlop26-Jul-21 20:37 
AnswerRe: How to copy DataTable contents into SQLite table? Pin
OriginalGriff26-Jul-21 21:06
mveOriginalGriff26-Jul-21 21:06 
GeneralRe: How to copy DataTable contents into SQLite table? Pin
Alex Dunlop26-Jul-21 21:16
MemberAlex Dunlop26-Jul-21 21:16 
GeneralRe: How to copy DataTable contents into SQLite table? Pin
Alex Dunlop26-Jul-21 22:58
MemberAlex Dunlop26-Jul-21 22:58 
GeneralRe: How to copy DataTable contents into SQLite table? Pin
OriginalGriff26-Jul-21 23:09
mveOriginalGriff26-Jul-21 23:09 
GeneralRe: How to copy DataTable contents into SQLite table? Pin
Alex Dunlop27-Jul-21 0:39
MemberAlex Dunlop27-Jul-21 0:39 
AnswerRe: How to copy DataTable contents into SQLite table? Pin
Richard Andrew x6428-Jul-21 2:36
professionalRichard Andrew x6428-Jul-21 2:36 
QuestionRTD communication error (COM) / .ConnectData(Int32 topicId, Object[]& parameters, Boolean& newValue) Pin
Juliano Zucatti26-Jul-21 10:14
MemberJuliano Zucatti26-Jul-21 10:14 
QuestionHow to shuffle an array VS Windows Form Application? Pin
Sofi081326-Jul-21 0:26
MemberSofi081326-Jul-21 0:26 
AnswerRe: How to shuffle an array VS Windows Form Application? Pin
OriginalGriff26-Jul-21 0:40
mveOriginalGriff26-Jul-21 0:40 
GeneralRe: How to shuffle an array VS Windows Form Application? Pin
Sofi081326-Jul-21 1:22
MemberSofi081326-Jul-21 1:22 
AnswerRe: How to shuffle an array VS Windows Form Application? Pin
Richard MacCutchan26-Jul-21 0:42
mveRichard MacCutchan26-Jul-21 0:42 
QuestionHow to find average value for duplicate keys in Dictionary? Pin
Alex Dunlop24-Jul-21 4:29
MemberAlex Dunlop24-Jul-21 4:29 
AnswerRe: How to find average value for duplicate keys in Dictionary? Pin
Alex Dunlop24-Jul-21 6:29
MemberAlex Dunlop24-Jul-21 6:29 
GeneralRe: How to find average value for duplicate keys in Dictionary? Pin
Gerry Schmitz24-Jul-21 6:44
mveGerry Schmitz24-Jul-21 6:44 
AnswerRe: How to find average value for duplicate keys in Dictionary? Pin
OriginalGriff24-Jul-21 6:47
mveOriginalGriff24-Jul-21 6:47 

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.