Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6134643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:22:51+00:00 2026-05-23T17:22:51+00:00

I am learning the C# programming language and am making a payroll application add-on

  • 0

I am learning the C# programming language and am making a payroll application add-on for SAP business One. I have never used a treeview before and wanted to know how one goes about populating the tree items from a database. I am using Visual Studio 2010 and Microsoft SQL Server 2008.

I have one parent with 2 children, i.e.

- Component                        ....Parent
      Earnings                     ....child
      Deductions                   ....child

I want the Earnings child to show all results from a U_PD_description field where U_PD_type = “Earnings”, i.e

- Component                        ....Parent
          Earnings                     ....child
              Housing Allowance
              Mobile Phone Allowance
              Mileage Allowance
          Deductions                   ....child

and likewise for deductions. I have the following code for formload:

 private void frm_earn_deduct_setup_Load(object sender, EventArgs e)
        {
            // Get service instance
            var earnDeductMasterService = Program.Kernel.Get<IEarnDeductMasterService>();

            //Query database for all records that have earnings
            var earnings = from ed in earnDeductMasterService.GetAllEarnDeductMasters()
                           where ed.U_PD_type.Trim().Equals("Earnings".Trim(), StringComparison.CurrentCultureIgnoreCase)
                           select ed;

            if (earnings.Any(x => x != null))
            {
                //To populate subtree Earnings with U_PD_description results
                //.....some code here
            }
            else 
            {
                //Nothing to populate            
            }

            //.............................................................................
            //Query database for all records that have deductions
            var deductions = from ed in earnDeductMasterService.GetAllEarnDeductMasters()
                             where ed.U_PD_type.Trim().Equals("Deductions".Trim(), StringComparison.CurrentCultureIgnoreCase)
                             select ed;

            if (deductions.Any(x => x != null))
            {
                //To populate subtree Deductions with U_PD_description results
                //.....some code here
            }
            else
            {
                //Nothing to populate            
            }

            // Disable default items
            txt_amt_greater_than.Enabled = false; 
            bindingNavigatorDeleteItem.Enabled = false;

            // Call service instance
            earnDeductMasterBindingSource.DataSource = Program.Kernel.Get<IEarnDeductMasterService>().GetAllEarnDeductMasters().ToList();
        }

Can anyone show me an example on how to populate say the earnings subtree in treeView1?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:22:51+00:00Added an answer on May 23, 2026 at 5:22 pm

    If i understood correctly what you want, then here is example how to populate treeview:

    List<string> earnings = new List<string>() { "Housing Allowance", "Mobile Phone Allowance", "Mileage Allowance" };
    List<string> deductions = new List<string>() { "Housing Ban", "Mobile Phone Ban", "Mileage Ban" };
    
    treeView1.Nodes.Add("Component");//adding root node
    treeView1.Nodes[0].Nodes.Add("Earnings");//adding earnings child node
    treeView1.Nodes[0].Nodes.Add("Deductions");//adding deduction child node
    
    //adding all earnings to "Earnings" node
    foreach (string earning in earnings)
    {
        treeView1.Nodes[0].Nodes[0].Nodes.Add(earning);
    }
    
    //adding all deductions to "Deductions" node
    foreach (string deduction in deductions)
    {
        treeView1.Nodes[0].Nodes[1].Nodes.Add(deduction);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning the C# programming language and am making a payroll application add-on
I am learning the C# programming language and am making a payroll application add-on
I'm currently learning the fascinating J programming language, but one thing I have not
I am learning the C# programming language and am making a Payroll program addon
Do you recommend learning C++ using a template? Edit I have basic programming language
I'm learning Python as my second programming language (my first real one if you
Duplicate of: Learning to write a compiler Documentation on creating a programming language Learning
I started learning JavaScript a while ago. It's a fairly easy programming language considering
OS: Linux, Language: pure C I'm moving forward in learning C programming in general,
I am new to programming and am learning Python as my first language. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.