LoginSignup
0
0

cscの作法 その481

Posted at

概要

cscの作法、調べてみた。
練習問題やってみた。

練習問題

comboboxで、Datasourceを使わないで組み立てよ。

写真

image.png

サンプルコード

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 App
{
	public partial class Form1: Form {
		ComboBox comboBox1;
		Label lb1;
		Label lb2;
		public Form1() {
			Text = "ComboBox";
			comboBox1 = new ComboBox();
			comboBox1.Width = 100;
			comboBox1.Height = 25;
			comboBox1.Left = 50;
			comboBox1.Top = 50;
			this.Controls.Add(comboBox1);
			comboBox1.Items.Add("");
			comboBox1.Items.Add("りんご");
			comboBox1.Items.Add("みかん");
			comboBox1.Items.Add("ぶどう");
			comboBox1.Items.Add("なし");
			comboBox1.Items.Add("もも");
			comboBox1.SelectedIndex = 0;
			comboBox1.SelectedValueChanged += comboBox1_SelectedIndexChanged;
			lb1 = new Label();
			lb1.Text = "disp";
			lb1.Left = 50;
			lb1.Top = 150;
			this.Controls.Add(lb1);
			lb2 = new Label();
			lb2.Text = "value";
			lb2.Left = 150;
			lb2.Top = 150;
			this.Controls.Add(lb2);
		}
		private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) {
			lb2.Text = comboBox1.SelectedItem.ToString();
		}
		[STAThread]
		public static void Main() {
			Application.Run(new Form1());
		}
	}
}





以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0