Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Assume that we want to write the code for the following. If the user types a string into the text portion of a combo

1. Assume that we want to write the code for the following. If the user types a string into the text portion of a combo box named cboNames then as soon as the user types the return key ( key) the program should add that name to the Items list and remove the string from the Text property. How would you finish this method to do so?

private void cboNames_KeyPress(object sender, KeyPressEventArgs e)

{

}

the code below is my guess, is this right?:

private void cboNames_KeyPress(object sender, KeyPressEventArgs e)

{

cboNames.Text = cboNames.Text.Trim();

cboNames.Items.Add(cboNames.Text);

cboNames.Text = String.Empty;

}

My other question is:

2. Write instructions that will do the following. It will open an output file with the directory name options.txt. It will write each of the items in a list box named lstOptions onto the output file as a line. When the last item is written, close the file.

Here's what i think it should the code should look like:

StreamWriter outputFile;

string theName

outputFile=File.CreateText(options.txt);

while (!outputfile.EndOfStream)

{

theName = outputFile.WriteLine();

lstOptions.Items.Add(theName);

}

namesFile.Close();

The questions are related to C#

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions

Question

5. Identify three characteristics of the dialectical approach.

Answered: 1 week ago

Question

7. Identify six intercultural communication dialectics.

Answered: 1 week ago