Click here to Skip to main content
15,891,828 members
Home / Discussions / C#
   

C#

 
GeneralRe: casting from interface instance back to generic instance ? Pin
BillWoodruff24-Apr-20 2:41
professionalBillWoodruff24-Apr-20 2:41 
GeneralRe: casting from interface instance back to generic instance ? Pin
Richard Deeming24-Apr-20 3:26
mveRichard Deeming24-Apr-20 3:26 
GeneralRe: casting from interface instance back to generic instance ? Pin
BillWoodruff24-Apr-20 4:52
professionalBillWoodruff24-Apr-20 4:52 
GeneralRe: casting from interface instance back to generic instance ? Pin
Richard Deeming24-Apr-20 4:59
mveRichard Deeming24-Apr-20 4:59 
AnswerRe: casting from interface instance back to generic instance ? Pin
jschell26-Apr-20 9:59
jschell26-Apr-20 9:59 
AnswerMessage Closed Pin
23-Apr-20 2:41
Corrie Lang23-Apr-20 2:41 
GeneralRe: During Pin
OriginalGriff23-Apr-20 3:15
mveOriginalGriff23-Apr-20 3:15 
QuestionRefreshing data on a parent form at child close Pin
Uranium-23521-Apr-20 20:24
Uranium-23521-Apr-20 20:24 
I've worked a lot to try to get this working, but after several errors and trials, i've tried two things without error, but it doesn't work

here is my customer list load code

C#
SQLiteParameter[] param = {};
// MessageBox.Show("ran?");
 customerList.Rows.Clear();

 DataTable searchinfo = database.query_search("SELECT id, firstname, lastname FROM customers", param);

 foreach (DataRow row in searchinfo.Rows)
 {
     customerList.Rows.Add(row[0].ToString(), row[1].ToString() + " " + row[2].ToString());
 }
 statusLabel.Text = searchinfo.Rows.Count.ToString() + " row(s) returned";


double clicking or clicking an 'edit' button successfully raises a child form

C#
private void customerList_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
    int index = e.RowIndex;

    DataGridViewRow row = customerList.Rows[index];
    String cid = row.Cells[0].Value.ToString();

    editcustomer editdiag = new editcustomer();
    editdiag.id = cid;
    editdiag.ShowDialog();
}


I used a timer to filter results from a textbox that starts and stops based on textchanged
C#
private void search_TextChanged(object sender, EventArgs e)
{
    if(queryInterval.Enabled == false)
        queryInterval.Start();
}


here is the 1000ms tick that stops itself after an idle match

C#
public void queryInterval_Tick(object sender, EventArgs e)
{
    if (lastQuery == search.Text)
    {
        queryInterval.Stop();
    }
    else
    {
        if (search.Text.Trim() != "" && search.Text.Length >= 3)
        {
            customerList.Rows.Clear();

            SQLiteParameter[] param = {
            new SQLiteParameter("@search", "%" + search.Text + "%") //used direct string for debug //search.Text)
        };

            DataTable searchinfo = database.query_search("SELECT id, firstname, lastname FROM customers WHERE firstname LIKE @search OR lastname LIKE @search", param);

            foreach (DataRow row in searchinfo.Rows)
            {
                customerList.Rows.Add(row[0].ToString(), row[1].ToString() + " " + row[2].ToString());
            }

            statusLabel.Text = searchinfo.Rows.Count.ToString() + " row(s) returned";
        }
        else if (search.Text.Trim() == "")
        {
            SQLiteParameter[] param = { };

            customerList.Rows.Clear();

            DataTable searchinfo = database.query_search("SELECT id, firstname, lastname FROM customers", param);

            foreach (DataRow row in searchinfo.Rows)
            {
                customerList.Rows.Add(row[0].ToString(), row[1].ToString() + " " + row[2].ToString());
            }
            statusLabel.Text = searchinfo.Rows.Count.ToString() + " row(s) returned";
        }
        else if (search.Text.Length < 3 && search.Text.Trim() != "")
        {
            //we do nothing
        }

        lastQuery = search.Text;
    }
}


i've tried directly running the load from the parent form on the child close

C#
private void editcustomer_FormClosed(object sender, FormClosedEventArgs e)
 {
     customers custForm = new customers();
     custForm.refresh(sender, e);
     custForm.customers_Load(sender, e);
 }


or blanked out the match text and started the timer

C#
private void editcustomer_FormClosed(object sender, FormClosedEventArgs e)
{
    customers custForm = new customers();
    custForm.lastQuery = "";
    custForm.queryInterval.Start();
}


I've done messageboxes in both the interval and the load and it does execute it, but the datagridview refuses to update. Is the parent form marked disabled till the form totally closes? Is there a better way to do this i'm not seeing?

yeah point is close the edit form and update the database and close the child form, have the parent update (name information updated, irrelevant if other data not seen is updated)

would iterating through the parent datagridview with the ID and upadting it manually work? I somehow doubt it if the other two is running, but not clearing the data and updating the new rows with the database data

thanks, sorry about the complexity of this
AnswerRe: Refreshing data on a parent form at child close Pin
OriginalGriff21-Apr-20 21:44
mveOriginalGriff21-Apr-20 21:44 
GeneralRe: Refreshing data on a parent form at child close Pin
Uranium-23521-Apr-20 22:48
Uranium-23521-Apr-20 22:48 
GeneralRe: Refreshing data on a parent form at child close Pin
OriginalGriff21-Apr-20 23:04
mveOriginalGriff21-Apr-20 23:04 
GeneralRe: Refreshing data on a parent form at child close Pin
Uranium-23522-Apr-20 23:27
Uranium-23522-Apr-20 23:27 
GeneralRe: Refreshing data on a parent form at child close Pin
OriginalGriff23-Apr-20 0:09
mveOriginalGriff23-Apr-20 0:09 
GeneralRe: Refreshing data on a parent form at child close Pin
Uranium-23523-Apr-20 10:46
Uranium-23523-Apr-20 10:46 
GeneralRe: Refreshing data on a parent form at child close Pin
OriginalGriff23-Apr-20 11:06
mveOriginalGriff23-Apr-20 11:06 
GeneralRe: Refreshing data on a parent form at child close Pin
Uranium-23524-Apr-20 17:53
Uranium-23524-Apr-20 17:53 
GeneralRe: Refreshing data on a parent form at child close Pin
OriginalGriff24-Apr-20 20:08
mveOriginalGriff24-Apr-20 20:08 
GeneralRe: Refreshing data on a parent form at child close Pin
Uranium-23525-Apr-20 19:42
Uranium-23525-Apr-20 19:42 
AnswerRe: Refreshing data on a parent form at child close Pin
#realJSOP22-Apr-20 7:15
mve#realJSOP22-Apr-20 7:15 
QuestionMaintain the Runing balance in Datagridview Pin
Mukhtar Ashiq21-Apr-20 9:04
Mukhtar Ashiq21-Apr-20 9:04 
SuggestionRe: Maintain the Runing balance in Datagridview Pin
Richard MacCutchan21-Apr-20 9:15
mveRichard MacCutchan21-Apr-20 9:15 
AnswerRe: Maintain the Runing balance in Datagridview Pin
ZurdoDev21-Apr-20 9:51
professionalZurdoDev21-Apr-20 9:51 
Questionextending an Enum with a function that returns a generic value ? Pin
BillWoodruff20-Apr-20 8:58
professionalBillWoodruff20-Apr-20 8:58 
AnswerRe: extending an Enum with a function that returns a generic value ? Pin
Richard Deeming20-Apr-20 9:34
mveRichard Deeming20-Apr-20 9:34 
GeneralRe: extending an Enum with a function that returns a generic value ? Pin
BillWoodruff20-Apr-20 11:56
professionalBillWoodruff20-Apr-20 11:56 

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.