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 9055387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:56:32+00:00 2026-06-16T13:56:32+00:00

Getting error when its casting in Listview: private void listView1_SelectedIndexChanged(object sender, EventArgs e) {

  • 0

Getting error when its casting in Listview:

    private void listView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        int a = 1;
        string theimage = textBox1.Text + @"\allimages\";
        foreach (ListViewItem item in listView1.SelectedItems)
        {   
            // 39 zero's + "1"
            string initValue = new String('0', 3) + "0";
            // convert to int and add 1
            int newValue = Int32.Parse(initValue) + a;
            // convert back to string with leading zero's
            string newValueString = newValue.ToString().PadLeft(4, '0');

            string imageslist =  "product" + newValueString + "img";
            string[] images = Directory.GetFiles(theimage, imageslist + "*.jpg");

            // Cast the Picturebox
            PictureBox myPicBox = new PictureBox();
            myPicBox.Location = new Point(7, 240);
            myPicBox.Size = new System.Drawing.Size(140, 140);
            myPicBox.SizeMode = PictureBoxSizeMode.AutoSize;
            myPicBox.Margin = new Padding(3,3,3,3);
            myPicBox.Visible = true;
            myPicBox.Image = new Bitmap(images[1]);
            Controls.Add(myPicBox);
            System.Diagnostics.Debugger.Break();
            //List<PictureBox> pictureBoxList = new List<PictureBox>();
        }

    }

Its my error:

Error 1 ‘test.Form1.PictureBoxSizeMode()’ is a ‘method’, which is not valid in the given context C:\Users\radiaku\Documents\Visual Studio 2008\Projects\test\test\Form1.cs 428 37 test

the code above working fine when I using button_click handler..

  • 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-16T13:56:33+00:00Added an answer on June 16, 2026 at 1:56 pm

    It sounds like your form has a method called PictureBoxSizeMode. You could either change the method name, or change the property setter to:

    myPicBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
    

    Changing the method name would be cleaner though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I doing some kind logic but its getting error? here my code private static
practicing programming with MyProgrammingLab and getting following compile error: ApartmentBuilding.java:4: error: expected its also
Hi i keep getting this error its an android.view.InflateException at line #9 xml Heres
I am getting error at criteria.setHorizontalAccuracy(5000); line. Its says criteria does not exists. Any
while playing this wav file in windows phone 7 its getting error. var stream
I am getting the following error message which I cannot understand why its happening
Hi i am getting error on this line. Its working in local. I just
I'm getting an error with its message as above when I tried to fetch
When I am trying to execute my program Its getting error like this -
Hello Friends i m getting blocked with a confusing error its seems simple but

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.