|
Quit reposting the same question. It doesn't make anyone answer your question any faster.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi everyone,
For a windows application that we are developing, there is a datagridview that holds the list of users in the system.... The datagridview should support sorting and also , the datgridview will be updated whenever a user is added to the system.
In such a scenario, which is the better option -
1) Using a BindingList as the Datasource to the gridview , update the bindinglist and call the ResetBindings to update the grid
OR
2) Use the DataGridView.Rows.Add / insert method to add rows
|
|
|
|
|
If your application is built using DataBinding then you have to use your first approach: always modify the data and reflect them by the UI,otherwise you will possibly get some nasty binding problems.
The second approach is useful if you use a model-view-presenter (or similar) model to fill the data into the DataGridView in the View.
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
The issue is that we are get frequent updates to the GridView , as far as i know , the ResetBindings will reread all the items in the list and refresh their displayed values. Will that be a performance issue
|
|
|
|
|
so here quick and dirt code to illustrate problem i have.
PROBLEM: when you have controls more that few, it tooks a lot of time for redraw them all.
this redrawing it visible and horrible.
even if you using custom control with (i think) faster repaint, it nosense...
so, maybe there's some styles or properties or something to make it faster?
or some other techniques?
--
yours,
mrRobot.
-- modified at 6:29 Monday 17th September, 2007
as i found here:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2044742&SiteID=1
there is no good solution for this problem. it possible to freeze window/control for repainting, but no speedup at all. sad.
using System;
using System.Drawing;
using System.Windows.Forms;
namespace custCompTest2
{
public class custCompTest2 : Form
{
public custCompTest2()
{
this.Name = "custCompTest2";
this.Text = "custCompTest2";
this.ClientSize = new System.Drawing.Size(400, 400);
for(int n=0; n<800; n++)
this.Controls.Add( (new tgC()) );
}
protected override void OnSizeChanged(EventArgs e)
{
this.SuspendLayout();
int x=0, y=0, w=Width/40, h=Height/21;
foreach (Control c1 in Controls)
{
c1.Location = new Point(x,y);
c1.Size = new Size(w,h);
if(x+w*2+1<Width) { x+=w; } else { x=0;y+=h; }
}
this.ResumeLayout(false);
}
protected override void OnLoad(EventArgs e)
{
this.OnSizeChanged(e);
}
[STAThread]
static void Main()
{
Application.Run(new custCompTest2());
}
}
public class tgC : Control
{
public tgC()
{
this.SetStyle(
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.DoubleBuffer |
ControlStyles.ResizeRedraw
, true);
}
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
g.DrawRectangle(Pens.Black, 1,1, Width-2, Height-2);
}
}
}
|
|
|
|
|
MrRobot wrote: for(int x=0; x {
for(int y=0; y {
How many Controls are there? (part of your source, starting with a less-than sign, got eaten
by the HTML interpreter)
Is this the actual code that is slow, or just something that looks like it?
Is it really the painting that is slow (try minimize-restore), or just the loading of the form?
IMO UserControls don't help speeding up the painting.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
hi,
sorry posting problems, me first time at codeproject.
i updated post. so, as you can see Controls are lot.
and with resizing it looks so ugly.
i still don't know is it possible speedup this some realy custom hints like WndProc or not...
|
|
|
|
|
Hi,
your tgC control is very simple, making it DoubleBuffered won't help;
you might try to make its container (the Form) DoubleBuffered though (that is where
the complexity is, due to the high number of Controls).
Why do you need/want tgC Controls in the first place? if all they do is draw a Rectangle,
they are not worth the trouble. This is what I would do:
- eliminta tgC class;
- add a Panel to the Form;
- make that Panel double-buffered;
- give it an OnPaint that draws all required shapes;
- if other events on tgC were going to be used, implement them on the Panel instead;
e.g. write simple code to convert a Panel.MouseClick to a Click in the right rectangle...
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
i already wrote sort of tgC class before post message. and it's ok with calculating mouse. was working until i realize i need tooltip and some other standart things. this is problem. seems it's also possible to do,
but also it seems stupid to reimpliment some things already exist. heh.
|
|
|
|
|
Using Controls is comfortable but does not lead to the highest performance, the choice
is yours.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
no doubt. but comparing mfc application i have here with about ~500 controls it possible to guess winforms 100 times slower or it working some different way... hmm, strange...
|
|
|
|
|
The Control class in the .NET Framework is a bit heavier than the base class in MFC. Putting 800 controls on a form will take forever to render, no matter what you do. Even then, the MFC code is probably not using true "controls", but lighter-weight custom windows, or a rendering engine.
Think of the number of WM_PAINT messages going to all those windows. That's 800 seperate paint events. In the case of user controls, even worse, since the paint event is going to the user control, then there's another paint event fired for the child controls of the user control. Things are getting ugly pretty fast, aren't they?
The less controls you have, the better, period. Under 50 controls and you'd be doing much better.
|
|
|
|
|
so, as mfc layng on winapi, i guessing winforms also using\extending winapi gdi. this way it should be possibility make redrawing faster. or i am wrong? will be great to have answer from winforms developers.
also:
as guessing .net similar to java i wrote kind of same code on java. with same buttons it works some faster but possible to say similar. BUT if instead buttons i'm using custom control(the same primitive tgC drawing rectangle) it's rocket!!!
and for winforms seems nosence is it button or lightweight tgC. it also question to winforms developers.
java tester code(same fast and dirty):
import java.awt.*;
public class jframef extends java.awt.Frame {
public jframef() {
initComponents();
}
private void initComponents() {
addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentResized(java.awt.event.ComponentEvent evt) {
formComponentResized(evt);
}
});
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
public void windowOpened(java.awt.event.WindowEvent evt) {
formWindowOpened(evt);
}
});
pack();
}
private void formWindowOpened(java.awt.event.WindowEvent evt) {
this.setLayout(null);
this.setSize(400,400);
for(int n=0; n<800; n++) {this.add( new tgC() );}
}
private void formComponentResized(java.awt.event.ComponentEvent evt) {
int n=0;
int width = this.getBounds().width/41;
int height = this.getBounds().height/21;
for(int x=4; x< this.getBounds().width-width; x+=width) {
for (int y=24; y<this.getBounds().height-height; y+=height) {
if (n<this.getComponentCount())
this.getComponent(n++).setBounds(x, y, width, height);
}
}
System.out.println("DONE");
}
private void exitForm(java.awt.event.WindowEvent evt) {
System.exit(0);
}
public static void main(String args[]) {
new jframef().show();
}
}
class tgC extends java.awt.Component {
public void paint(Graphics g){
g.drawRect(1, 1, getBounds().width-2, getBounds().height-2);
}
}
|
|
|
|
|
as i found here:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2044742&SiteID=1
there is no good solution for this problem. it possible to freeze window/control for repainting, but no speedup at all. sad.
|
|
|
|
|
Hi all ,Presently i am working on a task i.e.,i am having a toolstrip , i added textbox,RB,Label,Checkbox,etc , when i select a control on toolstrip,a run time control has to generate and paste on panel ,But i am not able to drag & drop the control to any place on the panel and make a new selection . And the other thing is when i click a new generated textbox ,it has to show the Textbox edges like in vs toolbox and after that i have to set properties for that runtime generated textbox or radiobutton .Actually, it has to work like VS.Net 2005 Toolbox with some controls on it -- this is actual idea
Waiting for help Urgently---
D.V.Sriram
|
|
|
|
|
Anyone got an idea on how to have a RichTextBox an image as a background?
Thanks in advance
|
|
|
|
|
|
Hi guys and gals.
I need to make use of the WebBrowser control in .NET 2005. I am trying to pass the proxy settings to the Browser but get the following Error Message.
Error Code: 502 Proxy Error. The ISA Server denied the specified
Uniform Resource Locator (URL). (12202)
IP Address: 10.13.67.5
Date:
Server:
Source: proxy
Can someone maybe tell me what the syntax is for using this control.
Regards,
Elizma
|
|
|
|
|
Do not put "Urgent" in your subject line, it really turns most people around here away. Just a friendly pointer
"Try asking what you want to know, rather than asking a question whose answer you know." - Christian Graus
|
|
|
|
|
Hi
RunTime How to Set A Object Type.
< Dim OBJvalue As String = "Yellow"
Dim OBJType As String = "Color">
I have this type two variables..
At run time create a object . that object value is from OBJValue.
That Object Type is What i mention in OBJType Variable...
Sample:
My Object type is Color it is value is yellow.. How i want write code for this
Thanks & Regards,
Sathiskumar.M
|
|
|
|
|
In this specific situation use
string value = "Yellow";
Color c = Color.FromKnownColor((KnownColor)Enum.Parse(typeof(KnownColor), value));
Generally, some type must be able create it's instance from a string. Assuming that it has a constructor which takes a string, you can use following code:
string type = "Temporary.MyType";
string value = "1,2,4";
MyType create = (MyType)Type.GetType(type).GetConstructor(new Type[] { typeof(string) })
.Invoke(new object[] { value });
namespace Temporary
{
public class MyType
{
int[] data;
public MyType(string str)
{
string[] numbers = str.Split(',');
data = new int[numbers.Length];
for (int i = 0; i < data.Length; i++) {
data[i] = int.Parse(numbers[i]);
}
}
public int[] Data
{
get { return data; }
}
}
}
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
Hi,
I'm developing a WinForms (VB.NET 2.0) application where I have a user control which contains several fixed controls (toolstrip, buttons, panels, etc.).
This works just fine - the problem is that I want one (and only one) Panel control within my user control to act as a container where other controls can be placed in the form designer.
I can set a designer attribute for the entire user control which causes the entire user control to be a container - but I only want one specific Panel control in the user control to act as a container.
How can this be done?
Please help, TIA
/B
-- modified at 5:29 Thursday 13th September, 2007
|
|
|
|
|
|
Getting a user control to act as a container is pretty easy :
After creating a user control in VS 2005, the class code should look something like this:
<br />
Public Class MyUserControl1<br />
<br />
End Class<br />
Just add the following attribute to the class :
<br />
< System.ComponentModel.Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", GetType(IDesigner)) > _<br />
Public Class MyUserControl1<br />
<br />
End Class<br />
That should do the trick
If you (or anybody else) find a solution to my problem (read my first post in this thread), please let me know... PLEEEEEESE
/B
|
|
|
|
|
Take a look at my TaskPane control, here:
http://www.codeproject.com/useritems/MSOfficeTaskPane.asp[^]
It does what you're asking. You can see how to set up the designer control properties to get everything to behave the way you want.
The early bird who catches the worm works for someone who comes in late and owns the worm farm. -- Travis McGee
|
|
|
|