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 WinLists
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
///
/// Метод загрузки главной формы
///
///
///
private void MainFormLoad(object sender, EventArgs e)
{
lblOutput.Visible = false;
}
///
/// Вычисление решения по нажатию на кнопку
///
private void btnLaunchClick(object sender, EventArgs e)
{
// Разбить строку на слова
if (lbItems.SelectedIndex == -1) {
MessageBox.Show("Выберите элемент из списка!");
return;
}
var words = Convert.ToString(lbItems.Items[lbItems.SelectedIndex]).Split(' ');
// Пройтись по каждому слову, сформировать строку ответа
string output = "";
foreach (var word in words)
{
output += word.Substring(1, word.Length - 1); // Убираем первую букву слова
output += " ";
}
// Обновляем надпись
lblOutput.Visible = true;
lblOutput.Text = output;
}
}
}