简体   繁体   中英

c#: Access a file image when a combobox index is selected

I have to access photos from a file whenever I select a Combobox Index. the photo and information related to it needs to be displayed on the form. I am unsure how to access the file photo using a pathname.

Below I have a portion of my code. The combobox contains city names.

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();

        }

    }

I assume your question is How to access the file photo using a pathname .

The answer is

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

Bang! Voila! Good luck!!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM