473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

drawing my own control - slow at runtime

I had to draw my own control because I couldn't find any control doing what
I wanted it to do. This control has a grid that I need to have control over.
To do that, I draw each line of the grid using a 1pixel pictureBox. I also
need "boxes" to be placed within that grid depending on data pulled from my
dataset. I also used pictureBox controls for that. All those components that
I use to draw my control are added to the controls collection of the parent
control. The problem is that when I do a myControl.controls.clear() to clear
the control before I redraw it, I can see each line and each box being
deleted one by one and that happens pretty slowly. I didn't have a chance to
test on other computers but the computer I'm using is decent (1Ghz with
512Mb of RAM).

Am I having the wrong approach to solve my problems or is there something I
can do to speed up the clear method?

Thanks

B.
Nov 20 '05 #1
8 5632
Hi Benoit,

At a guess I'd say wrong approach. ;-)

I don't understand what you are doing, but "draw each line of the grid
using a 1pixel pictureBox" makes me wince!!

Have you thought about actually <drawing> your lines and boxes using the
Draw functions of the Graphics object?

Regards,
Fergus
Nov 20 '05 #2
oops, I guess that my inexperience with .net shows here :)

Are lines created with the Draw function considered as components or
objects? Can I add them to a collection of controls so that they belong to a
control?

"Fergus Cooney" <fi******@tesco.net> wrote in message
news:OY**************@TK2MSFTNGP11.phx.gbl...
Hi Benoit,

At a guess I'd say wrong approach. ;-)

I don't understand what you are doing, but "draw each line of the grid
using a 1pixel pictureBox" makes me wince!!

Have you thought about actually <drawing> your lines and boxes using the Draw functions of the Graphics object?

Regards,
Fergus

Nov 20 '05 #3
Hi Benoit,

What control are you using for your grid?

The lines that you draw are just lines of pixels. They aren't controls or
objects. They don't exist except as pixels in a bitmap. And even then, they
will get wiped out and have to be redrawn when yourever form gets covered and
uncovered.

Typically, if you are drawing your own control, you write code to handle
the Paint event. This event supplies a Graphics object which you can use to do
your drawing with. There are a lot of drawing functions - to do lines,
circles, ellipses, rectangles, text in various flavours. There are also
functions which will do the drawing of various controls, like buttons,
checkboxes, etc, etc.

What exactly are you trying to achieve? And what's wrong with the
available controls?

Regards,
Fergus
Nov 20 '05 #4
"Benoit Martin" <bm*********@hotmail.com> scripsit:
Are lines created with the Draw function considered as components or
objects? Can I add them to a collection of controls so that they belong to a
control?


Do you draw the lines directly onto the control or du you use
pictureboxes?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #5
"Benoit Martin" <bm*********@hotmail.com> scripsit:
I had to draw my own control because I couldn't find any control doing what
I wanted it to do. This control has a grid that I need to have control over.
To do that, I draw each line of the grid using a 1pixel pictureBox. I also
need "boxes" to be placed within that grid depending on data pulled from my
dataset. I also used pictureBox controls for that. All those components that
I use to draw my control are added to the controls collection of the parent
control. The problem is that when I do a myControl.controls.clear() to clear
the control before I redraw it, I can see each line and each box being
deleted one by one and that happens pretty slowly. I didn't have a chance to
test on other computers but the computer I'm using is decent (1Ghz with
512Mb of RAM).


You will have to create virtual controls on the control. Remove the
pictureboxes and draw the data (grid, etc.) directly onto the form.
Then you check in the appropriate events if the user clicks a cell and
position a single textbox which is instantiated on the control on this cell.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #6
Benoit,
In addition to the Fergus's & Herfried's comments about doing the drawing
yourself with the Graphics object (in the Paint event OnPaint override).

The microsoft.public.dotnet.framework.drawing newsgroups provides assistance
dedicated to Graphics & drawing.

Charles Petzold's book "Programming Microsoft Windows with Microsoft Visual
Basic .NET" from MS press provides a wealth of information on using the
Graphics object in .NET.

The following articles discusses how to create a .NET Line control that
wraps Win32 STATIC controls. useful for lines in dialog boxes (not grids per
se).
http://www.codeproject.com/cs/miscctrl/hvrules1.asp

Hope this helps
Jay

"Benoit Martin" <bm*********@hotmail.com> wrote in message
news:uH***************@tk2msftngp13.phx.gbl...
I had to draw my own control because I couldn't find any control doing what I wanted it to do. This control has a grid that I need to have control over. To do that, I draw each line of the grid using a 1pixel pictureBox. I also
need "boxes" to be placed within that grid depending on data pulled from my dataset. I also used pictureBox controls for that. All those components that I use to draw my control are added to the controls collection of the parent control. The problem is that when I do a myControl.controls.clear() to clear the control before I redraw it, I can see each line and each box being
deleted one by one and that happens pretty slowly. I didn't have a chance to test on other computers but the computer I'm using is decent (1Ghz with
512Mb of RAM).

Am I having the wrong approach to solve my problems or is there something I can do to speed up the clear method?

Thanks

B.

Nov 20 '05 #7
In addition to everyone's comments, drawing a grid can be accomplished if
you take a look at the ControlPaint class, I believe it contains a method
that allows you to perform Grid-Painting.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
"Benoit Martin" <bm*********@hotmail.com> wrote in message
news:uH*************@tk2msftngp13.phx.gbl...
: I had to draw my own control because I couldn't find any control doing
what
: I wanted it to do. This control has a grid that I need to have control
over.
: To do that, I draw each line of the grid using a 1pixel pictureBox. I also
: need "boxes" to be placed within that grid depending on data pulled from
my
: dataset. I also used pictureBox controls for that. All those components
that
: I use to draw my control are added to the controls collection of the
parent
: control. The problem is that when I do a myControl.controls.clear() to
clear
: the control before I redraw it, I can see each line and each box being
: deleted one by one and that happens pretty slowly. I didn't have a chance
to
: test on other computers but the computer I'm using is decent (1Ghz with
: 512Mb of RAM).
:
: Am I having the wrong approach to solve my problems or is there something
I
: can do to speed up the clear method?
:
: Thanks
:
: B.
:
:
Nov 20 '05 #8
Tom,
I was going to mention ControlPain.DrawGrid in my post, however I did not as
it draws a grid of dots, not a grid of lines.

It really depends on the kind of grid that Benoit wants. Benoit mention
lines, so I assumed he did not want a grid of dots.

Just a thought
Jay

"Tom Spink" <th**********@ntlworld.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
In addition to everyone's comments, drawing a grid can be accomplished if
you take a look at the ControlPaint class, I believe it contains a method
that allows you to perform Grid-Painting.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
"Benoit Martin" <bm*********@hotmail.com> wrote in message
news:uH*************@tk2msftngp13.phx.gbl...
: I had to draw my own control because I couldn't find any control doing
what
: I wanted it to do. This control has a grid that I need to have control
over.
: To do that, I draw each line of the grid using a 1pixel pictureBox. I also : need "boxes" to be placed within that grid depending on data pulled from
my
: dataset. I also used pictureBox controls for that. All those components
that
: I use to draw my control are added to the controls collection of the
parent
: control. The problem is that when I do a myControl.controls.clear() to
clear
: the control before I redraw it, I can see each line and each box being
: deleted one by one and that happens pretty slowly. I didn't have a chance to
: test on other computers but the computer I'm using is decent (1Ghz with
: 512Mb of RAM).
:
: Am I having the wrong approach to solve my problems or is there something I
: can do to speed up the clear method?
:
: Thanks
:
: B.
:
:

Nov 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: padawan | last post by:
I have a winforms control that draws a rectangle for a boarder and positions some graphical elements around the control to create the boarder effect I desired. In the control I have overriden the...
0
by: fragget | last post by:
Does anyone have experience drawing a selection box around runtime controls. I foundthe ControlPaint.DrawSelectionRectangle (or whatever it is, however it doesn't have the nubs for resizing the...
1
by: msnews.microsoft.com | last post by:
I'd like to hear your thoughts on best methods for populating drop down list controls. I have states and countries drop down lists that don't change often, so naturally I "hard code" them in the...
10
by: tshad | last post by:
I have a problem setting the background color of textbox on the fly. I tried using: applicantID.backcolor = "F6F6F6" and applicantID.backcolor = "#F6F6F6"
20
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
13
by: Metallicraft | last post by:
I have a vb6 application. On the main form is a picture box with one or two images and several pieces of text displayed in it. These are created on the fly using gdi32 routines that are all in a...
7
by: ddecoste | last post by:
I have a need to add a visual representation to some data in Access. I need to draw a matix of squares inside another square. I have all the data that I need in a record in Access. The data...
0
by: Olie | last post by:
I am writting a program that uses allot of images to build up the form. It has quite allot of fader and LED controls which update live. Originally the problem I had was that it would take ages to...
5
by: lazyvlad | last post by:
Hi, I'm writing here because this issue is becoming more annoying with each day it passes. So I have a form, a dataset with a few table adapters (3 to be precise) and a datagridview.The datagridview...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.