Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9160827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:49:46+00:00 2026-06-17T13:49:46+00:00

I have two comboBoxes . In first I select Brand, in the second I

  • 0

I have two comboBoxes. In first I select Brand, in the second I select the model. I want also to display a picture according to model choice. Everything seemed to work until I added that FileInfo column. Now the code is not working (I cant even choose the brand and model – comboboxes are empty). What is wrong:

        dtCategories = new DataTable();
        dtCategories.Columns.Add("CategoryID", typeof(int));
        dtCategories.Columns.Add("CategoryName", typeof(string));

        dtCategories.Rows.Add(0, "--Select--");
        dtCategories.Rows.Add(1, "Audi");
        dtCategories.Rows.Add(2, "BMW");
        dtCategories.Rows.Add(3, "Mercedes");

        dtItems = new DataTable();
        dtItems.Columns.Add("ItemID", typeof(int));
        dtItems.Columns.Add("ItemName", typeof(string));
        dtItems.Columns.Add("CategoryID", typeof(int));
        dtItems.Columns.Add("Obrazek", typeof(FileInfo));

        dtItems.Rows.Add(2, "A1", 1, "a1.jpeg");
        dtItems.Rows.Add(3, "A3", 1, "a3.jpeg");
        dtItems.Rows.Add(4, "A4", 1, "a5.jpeg");
        dtItems.Rows.Add(5, "Seria 1", 2, "bmw1.jpeg");
        dtItems.Rows.Add(6, "Seria 2", 2, "bmw3.jpeg");
        dtItems.Rows.Add(7, "Seria 3", 2, "bmw5.jpeg");
        dtItems.Rows.Add(8, "C Klasa", 3, "C Klasa.jpeg");
        dtItems.Rows.Add(9, "E Klasa", 3, "E Klasa.jpeg");
        dtItems.Rows.Add(10, "S Klasa", 3, "S Klasa.jpeg");


        cbCategory.DisplayMember = "CategoryName";
        cbCategory.ValueMember = "CategoryID";
        cbCategory.DataSource = dtCategories;

And :

        private void cbCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
        int categoryId = Convert.ToInt32(cbCategory.SelectedValue);
        if (categoryId > 0)
        {
            DataTable dtTemp = dtItems.Select(string.Format("CategoryID = {0}",  categoryId)).CopyToDataTable();

            DataRow drTemp = dtTemp.NewRow();
            drTemp["ItemID"] = 0;
            drTemp["ItemName"] = "--Select--";
            drTemp["CategoryID"] = 0;

            dtTemp.Rows.InsertAt(drTemp, 0);

            cbItems.DisplayMember = "ItemName";
            cbItems.ValueMember = "ItemID";
            cbItems.DataSource = dtTemp;
            pictureBox1.Image = Image.FromFile(dtTemp.Columns[3].ToString());

        }
        else if (cbItems.DataSource != null)
        {
            cbItems.SelectedIndex = 0;
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:49:47+00:00Added an answer on June 17, 2026 at 1:49 pm

    FileInfo is not a valid data type for a column of a DataTable. See DataColumn.DataType Property for more information.

    Do you receive an exception of some kind?

    It might be your image paths are not correct.
    You could try this code, which might be easier to debug:

    var imagePath = dtTemp.Columns[3].ToString();
    if (File.Exists(imagePath))
    {
        var image = Image.FromFile(imagePath);
        pictureBox1.Image = image;
    }
    else
    {
        throw new FileNotFoundException(); 
        // of course something more subtle is advisable
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two g:select comboboxes that I want to add to the multiple select
I have two comboboxes. First combobox is for selecting the manager and the second
I currently have two comboboxes on a form. The first combobox contains a list
I have got two comboboxes on my application. The first combobox can get all
I have two comboboxes: The first one is Language (English, Italian, French...) and the
I have two related ComboBoxes ( continents, and countries ). When the continents ComboBox
I'm learning MVVM. I have my View filling two comboboxes from ObservableCollection properties in
I have two classes (MVC view model) which inherits from one abstract base class.
I have two comboboxes: Enable monitoring: Yes/No and Operation mode: Client/Server The default value
I have two comboboxes on an form. Each has the values Yes and No.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.