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

  • SEARCH
  • Home
  • 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 8589227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:00:14+00:00 2026-06-11T23:00:14+00:00

I have problem with long time drawing controls in my smart device project .

  • 0

I have problem with long time drawing controls in my smart device project.

Here is code that freeze application for ~11s:

SAdr = this.ExecuteSQL("select * from dba." + table);
while (SAdr.Read())
{
    PictureBox pBox = new PictureBox();
    pBox.Image = Program.ByteArrayToImage((byte[])SAdr["IMGDATA"]);
    pBox.Name = String.Format("pictureBox{0}#{1}",nameKey ,Int16.Parse(SAdr[colName].ToString()));
    pBox.Width = pBox.Height = size;
    pBox.Left = marginL;
    pBox.Top = marginT;
    pBox.SizeMode = PictureBoxSizeMode.StretchImage;
    pBox.Click += new EventHandler(pBoxTow_Click);

    if (counter < cols)
        marginL += size + space;
    else
    {
        marginL = 10;
        marginT += size + space;
        counter = 0;
    }
    panel.Controls.Add(pBox);
    counter++;
}
panelCenter.Controls.Clear();
panelCenter.Controls.Add(panel);

This time is measure from line SAdr = this.ExecuteSQL("select * from dba." + table); to line with panelCenter.Controls.Clear();.

Any ideas how to improve this code?

  • 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-11T23:00:17+00:00Added an answer on June 11, 2026 at 11:00 pm

    Read the data from the table into an array (bye array probably, to store the images). Then once the data reading is finished, only then begin to create the controls. Populating the picturebox from the local array will be faster than reading each item from the table and simultaenously populating it.

    Keep the database operation separate from the GUI operation by making use of arrays.

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

Sidebar

Related Questions

I have a problem that i've struggled with for a long time. This problem
I have a problem where Device.Dispose() is taking a long time to execute when
I have problem with extremely long compiling time on my C++ code where I
I have a problem with a page that's taking a long time to refresh
I have a problem with Quicktime, that means, QTKit. A long time ago I
I'm trying to solve this problem for a long time. I have 2 forms,
My problem is simple: I have a long list of elements that I want
I have this problem since a long time and I cannot find anything to
I have this problem for a long time now, I have searched the web
I have a problem for a long time, I don't figure out where the

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.