|
Check the clipping of the graphics object that you get in the Paint event. It should be clipped to the area that needs redrawing, and if that area is smaller than the control, you only have to draw the cells needed to cover that area.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I did try only invalidating the regions that need to be redrawn, and it helped a bit, but not a whole lot. I guess I'll try also only computing and calling DrawString for the invalid cells too; thanks for the suggestion.
|
|
|
|
|
It is a hard art to master, but text can be drawn very fast under GDI+. There is just too much detail to go into, but you can look at my 'AdvancedTextBox' control in xacc.ide. The source code is on sourceforge.
To summarize:
- Tokenize data
- Optimize tokens by grouping similar ones (store this and 'invalidate' if the 'line/text' changes)
- Paint the groupings
I would also suggest sticking to monospace fonts. Then only 1 call is needed to get the width of a character.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
So, basically you're talking about ways to reduce the number of DrawString() calls, right? Tokenizing isn't a problem since it's just a series of bytes; some sections can be rendered differently because of selection or other highlighting, but this wouldn't be hard to keep track of.
This still leaves me with the problem of maintaining a precise layout, though. If I draw the text in this fashion, I'm limited by the default spacing (both space character width and line height) of the font, which often puts columns and lines way too far apart to be visually pleasing in a hex editor. Is there some method of controlling the way GDI performs text metrics?
|
|
|
|
|
Mr. Accident wrote: In extreme cases it can take around 20 to 30 milliseconds to draw the entire control.
To add: Only paint what you see, there is no need to paint the invisible parts of the control.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Also, avoid creating new objects (pens, brushes, fonts, ...) in your Paint handler.
What I typically do is have some class members to hold those, inside the Paint handler null-check them
and create new objects if necessary, and everywhere else set them back to null when they will have
to be replaced.
And lastly, whatever disposable object you create, don't forget to call Dispose() on it when
you no longer need it.
The net result is painting does not cause unnecessary GC activity.
|
|
|
|
|
...programatically?
many thanks!
----------------------------------------------------------
"unzip; strip; touch; finger; mount; fsck; more; yes; unmount; sleep" - my daily unix command list
|
|
|
|
|
Process.Start(@"video.avi"); will do it. If there is no program associated with the extension you will get an exception.
|
|
|
|
|
When should we use Application.Run(form1) or form1.ShowDialog()?
Thanks
|
|
|
|
|
Usually, Application.Run is called only once by Main(). ShowDialog is used to show a form in an already running application.
|
|
|
|
|
Thats not the question you have in mind, i believe you want to know the difference between .show() vs .showdialog().
.show() - opens a new form like the old form
.showdialog() - opens a new form but you can only select the old form when you close the new.
Try it.
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
i have created the dataset ,bindingsource, dataadapter and filled the dataset with data using the adapter, but the problem is how can i bind the data source to the textbox dynamically.
i tried this code segment but got an error
textBox1.DataBindings.Add(bindingSource1);
before comming this point i checked the dataset and it's count equal to the no of records in the table.
|
|
|
|
|
is there any one who can help me with this problem.i want to read data from the db and keep store them (in memory or HD ) and let user to navigate the data. i want to do this programmatic ally.i created the dataset, dataadapter and the bindingsource, but the problem is i failed to get the data to the textbox. i'm trying to navigate data using movenext(),moveprevius() methods in the bindingsource.
|
|
|
|
|
hii all
I have made the setup of my project. My problem is
I want before installation of my project the setup will first install the dot net framework. I have a exe of dot net framework.
Please help
Thanks in advance.
|
|
|
|
|
Goto setup project properties. There you will find a prerequisites button. There you can select Framework installation as prerequisite.
|
|
|
|
|
which installation Location i have to specify in the prerequisites.
Thanks
|
|
|
|
|
I guess its same location as my application option.
|
|
|
|
|
You can check if install the dot net framework, when initialize in your program. If not install, you can call the dot net package and install it.
|
|
|
|
|
After checking how can i call the dot net package to install it?
Thanks
|
|
|
|
|
i have error : cross thread operation not valid : Control 'FormTest' accessed from a thread other than the thread it was created on
i know there's a way called safe- thread but in my application, there's no control FormTest. FormTest is actually a Form.
What's happening?
Thanks
|
|
|
|
|
The Form class inherits Control. All Controls in .NET must be accessed from the same thread in which they are created.
I'm guessing you are creating another thread and then attempting to update something displayed on your form from that second thread, correct? This is a no-no. You need to use Control.Invoke() or Control.BeginInvoke() to do your updates. Look them up and then come back if you have questions about how to use the samples you find - there are literally millions of them on the net.
|
|
|
|
|
|
How to convert 8.76882E-2 to double like 0.0876
Thanks
|
|
|
|
|
Hi,
conversion to a longer form (short to int, int to long, float to double) are implicit;
they don't need a method call or a cast.
But what you want is formatting, not conversion. Formatting is handled by the ToString() method,
which optionally accepts a format specification. Read up on Double.ToString().
|
|
|
|
|
what if 8.7688E-2 is in string type. I want to convert it to double ?
|
|
|
|