【问题标题】:c#: Access a file image when a combobox index is selectedc#:选择组合框索引时访问文件图像
【发布时间】:2018-04-18 01:21:05
【问题描述】:

每当我选择组合框索引时,我都必须从文件中访问照片。照片和相关信息需要显示在表格上。我不确定如何使用路径名访问文件照片。

下面是我的一部分代码。组合框包含城市名称。

private void cmbHouseList_SelectedIndexChanged(object sender, EventArgs e)
    {
        if(cmbHouseList.SelectedIndex.ToString() == ofdHouse.FileName)
        {
            txtAddress.Text = house.Street;
            txtCity.Text = house.City;
            txtZip.Text = house.Postal;
            txtPrice.Text = house.Price.ToString();

        }

    }

【问题讨论】:

  • 我不知道这些文件名可能是什么,但是否有可能将它们命名为“1”、“0”、“3”等等?启动您的调试器 - 这就是您正在检查/测试的内容
  • 文件名是 Glendale、Mississauga、Brampton、Markham 和 Oakdale。城市名称是相同的。我必须通过文件名访问照片。

标签: c# combobox filenames


【解决方案1】:

我假设您的问题是如何使用路径名访问文件照片。

答案是

string Pathname; //Whatever pathname.
Bitmap bmp = new Bitmap(Pathname);

砰!瞧!祝你好运!!!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-05
    • 2013-08-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多