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

  • Home
  • SEARCH
  • 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 365333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:31:37+00:00 2026-05-12T13:31:37+00:00

I am now doing an application that shows the HDD usage in the system.

  • 0

I am now doing an application that shows the HDD usage in the system. For that I want to generate the grid and the controls (like progress bar and labels) dynamically to show the usage. Is there any XAML template available for this purpose?

  • 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-12T13:31:38+00:00Added an answer on May 12, 2026 at 1:31 pm

    I use the folowing code to generate controls dynamically in my code

    Label[] drivesLabel;
    Label[] percentageLabel;
    ProgressBar[] drivesProgress;
    int drivesCount = 0;
    
    private void DrawControls()
    {
        try
        {
            // Getting drive list.
            List<DriveInfo> driveList = GetHardDiskDrives();
            drivesCount = driveList.Count;
    
            // Initializing new Grid.
            Grid drivesGrid = new Grid();
            drivesGrid.Children.Clear();
            DrivesBorder.Child = drivesGrid;
    
            // Adding Rows and Colums to Grid.
            RowDefinition[] rows = new RowDefinition[2*drivesCount + 1];
            ColumnDefinition[] columns = new ColumnDefinition[6];
    
            // Draw Rows.
            for (int i = 0; i < 2*drivesCount + 1; i++)
            {
                rows[i] = new RowDefinition();
                drivesGrid.RowDefinitions.Add(rows[i]);
    
                // Setting Row height.
                rows[i].Height = (0 == i % 2) ? new GridLength( 5 ): new GridLength( 25 );
            }
            // Draw Columns.
            for (int i = 0; i < 6; i++)
            {
                columns[i] = new ColumnDefinition();
                drivesGrid.ColumnDefinitions.Add(columns[i]);
                if (i % 2 == 0)
                {
                    // Setting column width.
                    columns[i].Width = new GridLength(5);
                }
            }
    
            // Setting column width.
            columns[1].Width = new GridLength(60);
            columns[3].Width = new GridLength(180);
            columns[5].Width = new GridLength(60);
    
            // Draw Labels to show drive letters.
            drivesLabel = new Label[drivesCount];
    
            // Draw Progress bar to show drive usage.
            drivesProgress = new ProgressBar[drivesCount];
    
            // Draw Labels to show drive usage.
            percentageLabel = new Label[drivesCount];
    
            // Adding Labels and Progressbars to Grid.
            for (int i = 0, j = 1; i < drivesCount; i++, j++)
            {
                // Initialize Labels to show drives.
                drivesLabel[i] = new Label();
                drivesLabel[i].Content = driveList[i].Name;
                drivesLabel[i].Foreground = Brushes.Navy;
                Grid.SetRow(drivesLabel[i], i + j);
                Grid.SetColumn(drivesLabel[i], 1);
                drivesGrid.Children.Add(drivesLabel[i]);
    
                // Initialize ProgressBar to show usage.
                drivesProgress[i] = new ProgressBar();
                drivesProgress[i].FlowDirection = FlowDirection.LeftToRight;
                drivesProgress[i].HorizontalAlignment = HorizontalAlignment.Center;
                drivesProgress[i].VerticalAlignment = VerticalAlignment.Center;
                drivesProgress[i].Orientation= Orientation.Horizontal;
                drivesProgress[i].Value = 0;
                drivesProgress[i].Maximum = 100;
                drivesProgress[i].Width = 180;
                drivesProgress[i].Height = 18;
                Grid.SetRow(drivesProgress[i], i + j);
                Grid.SetColumn(drivesProgress[i], 3);
                drivesGrid.Children.Add(drivesProgress[i]);
    
                // Initialize Labels  to show usage in percentage.
                percentageLabel[i] = new Label();
                percentageLabel[i].Content = "0 %";
                Grid.SetRow(percentageLabel[i], i + j);
                Grid.SetColumn(percentageLabel[i], 5);
                drivesGrid.Children.Add(percentageLabel[i]);
    
                // Setting window height.
                SetWindowHeight(30);
            }
        }
        catch(Exception Ex) {}
    }
    

    The functions GetHardDiskDrives() and SetWindowHeight() are user defined functions. The jpb is to get harddrives and Set the window height according to the new controls added.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I'm doing something like this: RewriteRule ^/?logout(/)?$ logout.php RewriteRule ^/?config(/)?$ config.php I
Now that I've finnaly moved to doing some development/support work for Windows 2008 I
I'm currently doing something like this in some code I'm working on right now:
I've been doing ASP.NET development for a little while now, and I've used both
I've been doing plain old java objects programming for 10 years now, with Swing
I'm new to RhinoMock's just been doing state unit testing up till now. How
I m doing a stuf in JAVA, as it is working fine.. now i
About a half dozen times now, I’ve been doing a regular chore in Visual
So, I've been doing Java for a number of years now, but now I'm
Now that most of the major browsers support full page zoom (at present, the

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.