c#:选择组合框索引时访问文件图像
每当我选择组合框索引时,我都必须从文件中访问照片。照片和相关信息需要显示在表单上。我不确定如何使用路径名访问文件照片 下面是我的部分代码。组合框包含城市名称c#:选择组合框索引时访问文件图像,c#,combobox,filenames,C#,Combobox,Filenames,每当我选择组合框索引时,我都必须从文件中访问照片。照片和相关信息需要显示在表单上。我不确定如何使用路径名访问文件照片 下面是我的部分代码。组合框包含城市名称 private void cmbHouseList_SelectedIndexChanged(object sender, EventArgs e) { if(cmbHouseList.SelectedIndex.ToString() == ofdHouse.FileName) {
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();
}
}
我假设您的问题是如何使用路径名访问文件照片 答案是
string Pathname; //Whatever pathname.
Bitmap bmp = new Bitmap(Pathname);
砰!瞧!祝你好运 我不知道文件名可能是什么,但它们是否有可能被命名为“1”、“0”、“3”等等?启动调试器-这就是您正在检查/测试的文件名:Glendale、Missisauga、Brampton、Markham和Oakdale。城市名称是一样的。我必须通过文件名访问照片。