0

WPF の新機能。画像名がコンボボックスから選択されたときにフォームに画像を表示したい(画像はコンボを埋めるSQLデータベースに保存されます)。

これをどのように行うことができるかについて、誰もが例を知っていますか。コンボから選択するときにテキスト ボックスに入力するコードを追加しました。

   private void comboBoxDisplay_SelectionChanged(object sender, SelectionChangedEventArgs e)

    {
        string constring = "Data Source=tcp:****;Initial   Catalog=******;Persist Security Info=True;User ID=*******;Password=******";

        string Query = "select * from tables where Name='" +  comboBoxDisplay.SelectedItem.ToString() + "' ;";
        SqlConnection conDataBase = new SqlConnection(constring);
        SqlCommand cmdDataBase = new SqlCommand(Query, conDataBase);
        SqlDataReader myReader;

        try
        {
            conDataBase.Open();
            myReader = cmdDataBase.ExecuteReader();

            while (myReader.Read())
            {

                string sReid = myReader.GetInt32(0).ToString();
                string sName = myReader.GetString(1);
                string sPicture = myReader.GetString(3);

                txtReId.Text = sReid;
                txtName.Text = sName;
                txtPicture.Text = sPicture;

            }

        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
4

1 に答える 1