Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

having problom to save my property setting for my datagridview......

Posted on 2009-07-10
2
Medium Priority
?
272 Views
Last Modified: 2012-05-07
hi i want to save the setting when user select wich view they want to see on the gridview, the gridview have 3 or 4 different view. When user select the view, i want to be saved as setting....but it wont...
function wich sets the datagridview form......SetAutoReconForm();
 
 private void SetAutoReconForm(Operator oper)
        {
            Boolean showHide = Properties.Settings.Default.ReconAutoShowHide;
 
            btnRecon.Enabled = true;
            btnAbort.Enabled = false;
 
            oper.EnableEvents = false;
            int tmpRel = oper.CurrentRelation_ID;
            int tmpCli = oper.CurrentClient_ID;
            OperatorMode tmpMode = oper.CurrentMode;
            oper.CurrentMode = OperatorMode.Relation;
            GetRelations();
 
            
            //treeViewReconciliations.Nodes.Clear();
            dgvReconciliations.Rows.Clear();
 
            SettingReconciliation currentSetting;
            string settingnametmp = "";
            System.IO.DirectoryInfo reconDir = new System.IO.DirectoryInfo(ReconciliationInfo.ReconciliationDir);
            DsOperatorAccess.ClientRow[] myClientRows = Adra.AMEngine.AmEngine.Instance.GetClients(oper);
            if (toolStripMenuItemAllClients.Checked)
            {
 
                foreach (DsOperatorAccess.ClientRow cliRow in myClientRows)
                {
                    oper.CurrentClient_ID = cliRow.Client_ID;
 
                    //treeViewReconciliations.Nodes.Add(cliRow.Client_ID.ToString(), cliRow.ClientName.ToString());
                    object[] argsClient = { false, null, null, cliRow.Client_ID.ToString(), 0, cliRow.ClientName.ToString(), "Client" };
                    dgvReconciliations.Rows.Add(argsClient);
 
                    myRelationRows = AmEngine.Instance.GetClientRelations(myOper);
                    foreach (DsOperatorAccess.RelationRow relRow in myRelationRows)
                    {
                        oper.CurrentRelation_ID = relRow.Relation_ID;
 
                        // treeViewReconciliations.Nodes[cliRow.Client_ID.ToString()].Nodes.Add(relRow.Relation_ID.ToString(), relRow.Name);
                        object[] argsRelation = { null, false, null, cliRow.Client_ID.ToString(), relRow.Relation_ID.ToString(), relRow.Name, "Relation" };
                        dgvReconciliations.Rows.Add(argsRelation);
 
                        oper.CurrentMode = OperatorMode.Relation;
                        myReconList = AmEngine.Instance.GetReconciliations(oper);
                        myReconList.FriendlyNames.SortOnPriority();
 
                        foreach (SettingType reconType in myReconList.FriendlyNames)
                        {
                            TreeNode newTreeNode = new TreeNode(reconType.Value);
                            reconType.Tag = relRow;
                            newTreeNode.Tag = reconType;
                            currentSetting = ((SettingReconciliationList)reconType.Setting).GetReconciliationSetting(reconType.Name);
                            try
                            {
                                System.Reflection.Assembly a = System.Reflection.Assembly.LoadFrom(reconDir + "/" + currentSetting.ReconFile);
                                Type t = a.GetType("Adra.Reconciliation.ReconciliationTypeName");
                                IReconciliationTypeName settingReconciliation = (IReconciliationTypeName)Activator.CreateInstance(t);
                                settingnametmp = settingReconciliation.GetValue(myOper.LanguageName);
                            }
                            catch
                            {
                            }
                            newTreeNode.Text = newTreeNode.Text + " (" + settingnametmp + ")";
 
                            object[] argsRecons = { null, null, false, cliRow.Client_ID.ToString(), relRow.Relation_ID.ToString(), newTreeNode.Text, "Recon" };
                            //dgvReconciliations.Rows.Add(argsRecons);
                            if (toolStripMenuItemAutoReconShowHide.Checked && toolStripMenuItemAutoReconShowHide.Checked)
                            {
                                int indx = dgvReconciliations.Rows.Add(argsRecons);
                                dgvReconciliations.Rows[indx].Visible = false;
                            }
                            else
                            {
                                dgvReconciliations.Rows.Add(argsRecons);
                            }
 
                            //store the reconType object in the tag
                            dgvReconciliations.Rows[dgvReconciliations.Rows.Count - 1].Tag = reconType;
 
                        }
                    }
                }
                dgvReconciliations.Columns[0].Visible = true;
            }
            else
            {
 
                foreach (DsOperatorAccess.RelationRow relRow in myRelationRows)
                {
                    oper.CurrentClient_ID = relRow.Client_ID;
                    oper.CurrentRelation_ID = relRow.Relation_ID;
 
                    object[] argsRelation = { null, false, null, relRow.Client_ID, relRow.Relation_ID.ToString(), relRow.Name, "Relation" };
                    dgvReconciliations.Rows.Add(argsRelation);
                    //treeViewReconciliations.Nodes.Add(relRow.Relation_ID.ToString(), relRow.Name);
 
                    myReconList = AmEngine.Instance.GetReconciliations(oper);
                    myReconList.FriendlyNames.SortOnPriority();
 
                    foreach (SettingType reconType in myReconList.FriendlyNames)
                    {
                        TreeNode newTreeNode = new TreeNode(reconType.Value);
                        reconType.Tag = relRow;
                        newTreeNode.Tag = reconType;
                        currentSetting = ((SettingReconciliationList)reconType.Setting).GetReconciliationSetting(reconType.Name);
                        try
                        {
                            System.Reflection.Assembly a = System.Reflection.Assembly.LoadFrom(reconDir + "/" + currentSetting.ReconFile);
                            Type t = a.GetType("Adra.Reconciliation.ReconciliationTypeName");
                            IReconciliationTypeName settingReconciliation = (IReconciliationTypeName)Activator.CreateInstance(t);
                            settingnametmp = settingReconciliation.GetValue(myOper.LanguageName);
                        }
                        catch
                        {
                        }
                        newTreeNode.Text = newTreeNode.Text + " (" + settingnametmp + ")";
 
                        object[] argsRecons2 = { null, null, false, relRow.Client_ID, relRow.Relation_ID, newTreeNode.Text, "Recon" };
                        //dgvReconciliations.Rows.Add(argsRecons2);
                        if (toolStripMenuItemAutoReconShowHide.Checked == true)
                        {
                            int indx = dgvReconciliations.Rows.Add(argsRecons2);
                            dgvReconciliations.Rows[indx].Visible = false;
                        }
                        else
                        {
                            dgvReconciliations.Rows.Add(argsRecons2);
                        }
 
                        //store the reconType object in the tag
                        dgvReconciliations.Rows[dgvReconciliations.Rows.Count - 1].Tag = reconType;
                    }
                }
                dgvReconciliations.Columns[0].Visible = false;
            }
 
            oper.CurrentRelation_ID = tmpRel;
            oper.CurrentClient_ID = tmpCli;
            oper.CurrentMode = tmpMode;
 
            oper.EnableEvents = true;
            txtNoReconciled.Text = "0";
 
            if (chkBoxSelectAll.Checked)
            {
                foreach (DataGridViewRow dgr in dgvReconciliations.Rows)
                {
                    if (dgr.Cells["ReconType"].Value.ToString() == "Client")
                    {
                        dgr.Cells["ClientSelected"].Value = true;
                    }
                    else if (dgr.Cells["ReconType"].Value.ToString() == "Relation")
                    {
                        dgr.Cells["RelationSelected"].Value = true;
                    }
                    else if (dgr.Cells["ReconType"].Value.ToString() == "Recon")
                    {
                        dgr.Cells["ReconSelected"].Value = true;
                    }
                }
 
            }
            //do this last so check state right
            RefreshReconAutoForm();
        }
*************************************************************************************
Here is the function i where i want the settting to be saved....
 
 private void toolStripMenuItemAutoReconShowHide_Click(object sender, EventArgs e)
        {
            if (toolStripMenuItemAutoReconShowHide.Checked && toolStripMenuItemAllClients.Checked)
            {
                Properties.Settings.Default.ReconAutoShowHide = toolStripMenuItemAutoReconShowHide.Checked;
                SetAutoReconForm(myOper);
                //this.reconAutomaticShowHide1.Visible = true;
                //this.reconAutomaticShowHide1.BringToFront();
            }
            if (toolStripMenuItemAutoReconShowHide.Checked)
            {
                Properties.Settings.Default.ReconAutoShowHide = toolStripMenuItemAutoReconShowHide.Checked;
                SetAutoReconForm(myOper);
            }
            else
            {
                SetAutoReconForm(myOper);
            }
 
        }

Open in new window

0
Comment
Question by:Adnan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 

Author Comment

by:Adnan
ID: 24821359
the setting will not be saved when i close my application, but when app is running it save the setting, only when i close the application it wont save...?!
0
 

Accepted Solution

by:
Adnan earned 0 total points
ID: 24821890
ooh mi forgot to add this line in my function SetAutoReconForms :  toolStripMenuItemAutoReconShowHide.Checked = Properties.Settings.Default.ReconAutoShowHide;
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question