Question

In: Computer Science

The items in a listbox is treated as string. If we set the listbox Sorted property to True, the listbox will be sorted based on items' string value.

The items in a listbox is treated as string. If we set the listbox Sorted property to True, the listbox will be sorted based on items' string value. A listbox with items 2 and 10, the sorted output will be 10, 2 which is not numeric ascending sequence. 


If a listbox has only numbers, what would you do to display those items base on their numeric value in ascending order in the listbox?

Solutions

Expert Solution

Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication42
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
listBox1.Items.Add("3140");
listBox1.Items.Add("109");
listBox1.Items.Add("2");
listBox1.Items.Add("10");
listBox1.Items.Add("180");
  

  

}

private void button1_Click(object sender, EventArgs e)
{
List list = new List();

foreach (var o in listBox1.Items)
{
list.Add(Convert.ToInt16(o));
}

list.Sort();

listBox1.Items.Clear();

foreach (var o in list)
{
listBox1.Items.Add(o);
}
}

}
}


Related Solutions

Create program which sorts letters of a string based on ASCII value. The program will then...
Create program which sorts letters of a string based on ASCII value. The program will then print the sorted string to stdout. Use C programming language. - Only use stdio.h - Input prompt should say "Enter string of your choice: " - Remove any newline \n from input string - Implement sorting operation as a function. Should use selection sort algorithm, but you may use a different algorithm - Output should print sorted string on new line Example:     Enter...
a) Explain intuitively why denseness is a desirable property of a sample set in sampling-based planning....
a) Explain intuitively why denseness is a desirable property of a sample set in sampling-based planning. b) Explain intuitively why we want a low dispersion sample set in sampling-based planning.
FORUM DESCRIPTION A firm’s intrinsic value is an estimate of a stock’s “true” value based on...
FORUM DESCRIPTION A firm’s intrinsic value is an estimate of a stock’s “true” value based on accurate risk and return data. It can be estimated but not measured precisely. A stock’s current price is its market price—the value based on perceived but possibly incorrect information as seen by the marginal investor. From these definitions, you can see that a stock’s “true” long-run value is more closely related to its intrinsic value rather than its current price. Given the above what...
, we are given a set of n items. Each item weights between 0 and 1....
, we are given a set of n items. Each item weights between 0 and 1. We also have a set of bins (knapsacks). Each bin has a capacity of 1, i.e., total weight in any bin should be less than 1. The problem is to pack the items into as few bins as possible. For example Given items: 0.2, 0.5, 0.4, 0.7, 0.1, 0.3, 0.8 Opt Solution: Bin1[0.2, 0.8], Bin2[0.5, 0.4, 0.1], Bin3[0.7, 0.3] Each item must be placed...
This simulation question available sources is based upon a true set of facts. The information contained...
This simulation question available sources is based upon a true set of facts. The information contained in the simulation question was What is the Relationship Between the Fraud Triangle and Financial Statement Fraud? - Required First, search the Internet or refer to textbooks to learn as much as you can about the Fraud Triangle. Then, answer the following: 2. How can the Fraud Triangle detect/prevent financial statement fraud? Discuss how each of the three elements of the Fraud Triangle can...
True/false 1- The fair market value of property or services received in bartering must be included...
True/false 1- The fair market value of property or services received in bartering must be included in gross income. 2- Mr. Barley an accountant, accepted a painting for his office from his client in lieu of payment of his customary fee of $400 for preparation of a tax return. He must include the $400 income. 3- An ordinary expenditure is one which is commonly incurred by other businesses. 4- Rent and royalty expenses are deductible from adjusted gross income. 5-...
Q4-2 This simulation question available sources is based upon a true set of facts. The information...
Q4-2 This simulation question available sources is based upon a true set of facts. The information contained in the simulation question was What is the Relationship Between the Fraud Triangle and Financial Statement Fraud? - Required First, search the Internet or refer to textbooks to learn as much as you can about the Fraud Triangle. Then, answer the following: 1. What is the Fraud Triangle? Discuss your understanding of the Fraud Triangle and give examples of financial statement fraud for...
TRUE or FALSE 1) On a pro forma income statement, the value we enter for sales...
TRUE or FALSE 1) On a pro forma income statement, the value we enter for sales revenue is normally derived from our forecast.       2) One does not need to determine if the operating expenses are in line with industry averages. 3) Start-up expenses are those expenses that will be incurred by the business one time.   
The Patient Driven Payment Model (PDPM) is the CMS Medicare value based payment model set to...
The Patient Driven Payment Model (PDPM) is the CMS Medicare value based payment model set to go into effect in October 2019. How will it impact facility staffing patterns and resident reimbursement/billing?
a) Set out and explain three cash flow based valuation techniques for determining the intrinsic value...
a) Set out and explain three cash flow based valuation techniques for determining the intrinsic value of a company’s equity. b) Set out and explain two abnormal income based valuation techniques for determining the intrinsic value of a company’s equity. c) Provide a balanced discussion of the theoretical merits and weaknesses of each of the two types of model described in parts (a) and (b). d) Provide a summary of the empirical evidence relating to the performance of each type...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT