Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
U

User 11025596

@User 11025596
About
Posts
8
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • add row to datagridview by checking child node check box of treeview
    U User 11025596

    RESOLVED: Added an 'else' to the AfterCheck so it simply calls getChildNodesToGrid() I then updated private DataTable getFieldsTable() to add a counter and condition 'if (fileNode.Nodes[cnt].Checked)'. Don't know if this is proper programming but seems to work.

    private void tvFileMan_AfterCheck(object sender, TreeViewEventArgs e)
    {
    getFileAndColumns();
    if (e.Node.Nodes.Count > 0)
    {
    //this.CheckAllChildNodes(e.Node, e.Node.Checked);
    // Checked a file so get fields and check all fields except subfiles.
    e.Node.Expand();
    foreach (TreeNode tn in e.Node.Nodes)
    {
    if (tn.Nodes.Count.Equals(0))
    tn.Checked = e.Node.Checked;
    }
    getChildNodesToGrid();
    }
    else
    {
    e.Node.Expand();

                //if (tn.Nodes.Count.Equals(0))
                if (e.Node.Checked)
                {
                    //tn.Checked = e.Node.Checked;
                    getChildNodesToGrid();
                }
    
        }
    

    private DataTable getFieldsTable()
    {
    //original
    DataTable dt = new DataTable();
    dt.Columns.Add("ColumnName");
    dt.Columns.Add("FMFieldName");
    dt.Columns.Add("FMFieldNumber");
    dt.Columns.Add("FMFileNumber");
    dt.Columns.Add("FMFieldType");
    dt.Columns.Add("ResolvedValue");
    dt.Columns.Add("PointsToFileNumber");
    TreeNode fileNode = tvFileMan.SelectedNode;
    int cnt = 0;
    foreach (TreeNode tn in fileNode.Nodes)
    {
    if (tn.Nodes.Count == 0)
    {
    if (fileNode.Nodes[cnt].Checked)
    {
    DataRow dr = dt.NewRow();

                dr\["FMFieldName"\] = tn.Text.Substring(tn.Text.IndexOf("  - ") + 4);
                dr\["FMFieldNumber"\] = tn.Tag.ToString();
                dr\["FMFileNumber"\] = tn.Parent.Tag.ToString();
                dr\["ColumnName"\] = suggestName(tn.Text.Substring(tn.Text.IndexOf("  - ") + 4));
                //added by TEA 9/3/14 to get PointsToFileNumber in DataGrid
                if (dr\["PointsToFileNumber"\].ToString().Length > 0)
                {
                    dr\["ColumnName"\] = suggestName(tn.Text.Substring(tn.Text.IndexOf("  - ") + 4) + "txt");
                }
                dt.Rows.Add(dr);
                }
                cnt++;
            }
        }
    
    C# question csharp css database

  • add row to datagridview by checking child node check box of treeview
    U User 11025596

    I'm new to C# and am working on first project. I have a WINFORM that displays a treenode and a datagridview. I want selected items from the treenode to go to the datagridview. If I select the parent node of treenode all children go to datagridview but if I just expand the parent and select one of the children, nothing goes to datagrid. (selection of a treenode fires a method to get attributes of the item from sql table and it is the attributes that go to the grid + node value) When parent is selected 'if (e.Node.Nodes.Count > 0)' is true. When parent isn't selected but child is 'if (e.Node.Nodes.Count > 0)' is false. So my question is what code do I need to find child nodes that are checked/unchecked? Once I get correct code to find child node check, what code moves it to datagrid or delete from datagrid if child is unchecked?

    private void getChildNodesToGrid()
    {
    // get all child nodes add to dataGridView
    DataTable dt = getFieldsTable();
    dgvColumns.DataSource = dt;
    getAttributeSIDs();
    }

    private void tvFileMan_AfterCheck(object sender, TreeViewEventArgs e)
    {
    getFileAndColumns();
    if (e.Node.Nodes.Count > 0)
    {
    this.CheckAllChildNodes(e.Node, e.Node.Checked);
    // Checked a file so get fields and check all fields except subfiles.
    // Use this event handler to process actions from check box click
    e.Node.Expand();
    foreach (TreeNode tn in e.Node.Nodes)
    {
    if (tn.Nodes.Count.Equals(0))
    tn.Checked = e.Node.Checked;
    }
    getChildNodesToGrid();
    }

    C# question csharp css database

  • search or filter treenode display based on text input from user
    U User 11025596

    Pardon me. Had I known English wasn't understood here I would have made it painstakingly clear but thought my first sentence, "

    Quote:

    New to VS C# and inherited a partially developed C# Winform project. Need some guidance.

    said it all. Also I didn't see anywhere that you don't take kindly to folks learning. I'll make a note of that. But if my opening statement didn't work for you I would have thought an intelligent being such as yourself would have surmised my skill level based on the question. (go figure) It's very presumptuous of you to think I haven't gone through numerous tutorials and articles on the topic and while I've learned how to build the tree from a SQL source and update it, I did not find anything addressing my question and is why I came here hoping for some guidance. I'm so sorry I did that. I'll think twice about asking another. Have a good day. Thom

    Windows Forms question csharp database visual-studio data-structures

  • search or filter treenode display based on text input from user
    U User 11025596

    Okay. I got my answer from a respondent on MSDN. Since I'm in the process of learning the language, syntax, and nuances of Visual C# this is the kind of answer struggling people like me hope to receive from FORUMS like this. There is no way I would have known to do this or "Write It" without guidance.

    Quote:

    Hi Hawk73ku, According to your description, you'd like to find the specified treenode from the TreeView. I wrote a sample for you, Here are my steps. Step1: create a form with a textbox, a button and a treeview. Step2: set the button click event handler like this. List tnlist = new List();//collect the result nodes int count = -1;//used to record the index of the selectnode private void button1_Click(object sender, EventArgs e) { this.treeView1.Focus(); tnlist.Clear(); this.getallTreeNode(this.treeView1.Nodes, tnlist); if (tnlist != null && tnlist.Count > 0) { count++; if (count >= tnlist.Count) { count = 0; } this.treeView1.SelectedNode = tnlist[count]; } } private void getallTreeNode(TreeNodeCollection nodes, List ltn) { foreach (TreeNode tn in nodes) { if (tn.Text.ToLower().Contains(this.textBox1.Text.ToLower())) { ltn.Add(tn); } if (tn.Nodes.Count > 0) getallTreeNode(tn.Nodes, ltn); } } the getallTreeNode method in my code is used to collect the result treenodes to a list. Results: #TreeNode Class http://msdn.microsoft.com/en-us/library/system.windows.forms.treenode(v=vs.110).aspx If you have any other concern regarding this issue, please feel free to let me know. Best regards, Youjun Tang

    Windows Forms question csharp database visual-studio data-structures

  • search or filter treenode display based on text input from user
    U User 11025596

    Quote:

    Are you saying you don't know how to handle text input, and use the content to change the focus of your TreeView?

    As a newbie I'm not sure what your response means. I want the display to scroll based on user input in a textbox rather than using the scrollbar and mouse. If that's what you mean by your response, than yes, I don't know how.

    Windows Forms question csharp database visual-studio data-structures

  • search or filter treenode display based on text input from user
    U User 11025596

    Well that was no help at all. You think I didn't search for something close? I stepped through every one of those articles with tags VS, C#, and SQL. Not only is there nothing close but nothing near the planet and there isn't a Tag for Winforms. The project Social.Club might be useful but I can't get it to load and build per the instructions. Perhaps because I have VS 2013 and not VS 2010. Not sure. In any event it doesn't look like it contains an example of user text input to scroll the Tree display. Regards, Thom

    Windows Forms question csharp database visual-studio data-structures

  • search or filter treenode display based on text input from user
    U User 11025596

    Thanks but very few Winform samples in C# and none related to my question.

    Windows Forms question csharp database visual-studio data-structures

  • search or filter treenode display based on text input from user
    U User 11025596

    New to VS C# and inherited a partially developed C# Winform project. Need some guidance. Windows Form displays SQL results in a tree view with the intent of the user selecting item(s) from the list. You have to scroll the list and find item(s) you want to select. Items have a # and a name and most users know one or the other. Question: Is there a way to include a text box or something that would move the tree display to characters typed in the box? If yes how is it done in VS C#? Anyone have a sample project I could download? Doesn't have to be SQL data, could be a windows directory or something.

    Windows Forms question csharp database visual-studio data-structures
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups