|
Do not use a control for every little piece of content. This is too heavy weight.
softwarejaeger wrote: because i think you mean i shoudl draw lines and rectangles to draw the controls or?
Exactly that. And dont be scared. It is actually one of the funner parts of programming
|
|
|
|
|
and how can i interact with the cell then? i mean... clicking isn't really a problem, i get the coordinates of the mouse and so on... but... maybe selecting or changing... how to do that in you way? i mean if i see a good way to do this i would do this, but i think it's not that what i really need
|
|
|
|
|
When needed, you can put a 'proper' control there for the interaction, once done, remove the control.
|
|
|
|
|
could you make an example for that? i don't understand what you mean with a "proper" control
|
|
|
|
|
You're not running out of memory, you're running out of GDI handles (which produces visual errors and/or an OutOfMemoryException).
A process is limited to 10000 handles in Windows XP (even less in previous versions), and each Windows Forms control takes 1 handle (maybe even more than one).
Suggestions:
- virtualize your table (only allocate objects for the visible region)
- implement your table as a single Windows Forms control
|
|
|
|
|
what do you mean with "virtualize" your table? can you give an example?
and how should i implement my table as a single windows forms control? it is a user-control which contents the ~3000 other "cell"-user-controls... how could i implement as a single windows forms control?
|
|
|
|
|
Virtualizing means that while the user scrolls through the table, the controls that enter the visible region are created and the controls that leave the visible region are disposed.
Implement as single control: don't use UserControls. Your cells should not derive from any Windows Forms class. Then, in the Paint method of the table control, call the paint methods of your cell objects (pass them the Graphics object and the position to draw to).
|
|
|
|
|
ok... is there any "property" i can set for virtualizing or must i make that "manually" but how can i do this then? well i mean, i put all UserControls to their Location, and then disposing shouldn't be a problem, but how can i show them again?
and exactly that with the "grabbing" the Graphics object from the control and draw it is that what i want, but with wich method put i that graphics object to the panel? can you give an example?
thanks...
|
|
|
|
|
You have to do it manually. Whenever the user scrolls, dispose the controls going out of view and create new controls for the items coming into view.
Or, the alternative solution (IMHO better):
Use the Paint event of the control and draw using the e.Graphics object.
Something like this:
protected override void OnPaint(PaintEventArgs e) {
base.OnPaint(e);
foreach (Cell c in cells) {
c.Paint(e.Graphics, new Rectangle(...));
}
}
class Cell {
public void Paint(Graphics g, Rectangle r) {
}
}
You'll have to write the code to manage the cells and their drawing positions.
|
|
|
|
|
ok thanks, i'll test it tomorrow and will tell you if it works thanks
|
|
|
|
|
hello, and how can i make this to show only the controls, they're needed? With the method "Hide" and "Show"? To find out which isn't needed is no problem, but what must i tell my UserControls to say them, that they didn needed or needed now?
|
|
|
|
|
well... now i made following...
a table control (like i had before) and a panel... i load now all cells (usercontrols) and so on in a list...
at first i start the method(cellArrange()) which tolds the cells their right position... then and if i scroll or resize my control, i search for all cells in the list which are in the visible region... now when it is visible, it says "panel1.Controls.Add(cell)" and if it shouldnt visible "panel1.Controls.Remove(cell)" but i get the same errors like before (out of memory) what to do?
|
|
|
|
|
Can I ask *why* a datagrid isn't right for your project? There are a lot of 3rd party grid controls out there that can do custom editors if that's what you need.
|
|
|
|
|
softwarejaeger wrote: i think at my project in that form i have round about 3000 controls.
Can you remember what they all do???
|
|
|
|
|
softwarejaeger wrote: what do you mean with "obscene" number of controls... i think at my project in that form i have round about 3000 controls.
That's pretty obscene. I tried to put 3000 controls on a form, and it doesn't work properly. It never seems to finish drawing the controls so the program is overwhelmed by events, but there is no memory problems or graphics problems at all.
softwarejaeger wrote: what to do?
Debug.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Check your computer memory aswell, is your computer running low memory due to lare number of processes running.
And secondly, my friends suggestion might work out that your application might stuck out due to replication of the object in a loop.
|
|
|
|
|
Hi
I have 2 queries,1 query for datagrid anad the other for textbox in one form.
How can I use dataset,dataAdapter,dataview…?
Do I need one dataset or two?
Please help me
Thank you very much
|
|
|
|
|
Please post what exactly your problem is. What you want to do.
Ahsan Ullah
Senior Software Engineer
|
|
|
|
|
|
you need only one dataset.Add it with your table name in dataset, then while assiging it to datagrid and TextBox give the appropriate Datamember name .
like
datagrid.datamember = Tablename for textbox
datagrid.datamember = Tablename for datagrid.
datagrid.dataSource = datasetName.
|
|
|
|
|
but i have one table and 2 query
now do i need one dateset?
|
|
|
|
|
Hi all,
I started my first xml writeing /reading project
I want to save all the text in the textboxes of the form to an xml file ( save file) and then load it back later.
I have the writing XML down ( i think please let me know if you have ideas)
but here is an example of my output
?xml version="1.0" encoding="UTF-8"?
Root
FileInfo
Region Region="Region1" /
TourName TourName="mens2006" /
Username Username="rbarbrow" /
timestamp TimeStamp="9/2/2008 1:25:26 AM" /
/FileInfo
MatchInfo
Match TB_32_C="No Chatter" /
Match TB_32_U="1-North Carolina (32-2)" /
Match TB_32_L="16- Play-In-Winner" /
Match TB_32_S="Raliegh, N.C., Friday 7:10" /
Match TB_33_C="No Chatter" />
Match TB_33_U="8-Indiana (25-7)" /
Match TB_33_L="9-Arkansas (22-11)" /
Match TB_33_S="Ralegh, N.C., Friday, 9:30" /
/MatchInfo>
/Root
The idea is that i have textboxes TB_##_(U,S,L,C) and that i can read what textbox and what text and then read the text back in
the problem is that i can read the text with the .getattribute(i) method ("no chatter" or "1-North Carolina (32-2)") but i can not read the attribute name ( TB_32_C or TB_32_U)
So question 1 is: How do i read the Attribute NAME?
question 2 is there a way to read only things in the MatchInfo Node? ( if node is the right word)
Thanks so much for any help
|
|
|
|
|
How do i read the Attribute NAME?
Use XmlTextReader
is there a way to read only things in the MatchInfo Node
Use XmlNode
Ahsan Ullah
Senior Software Engineer
|
|
|
|
|
my cup runith over
Like i said in my orginal post this is my first time working with XML at all let alone in c#
I got the xml reader part thats how i am able to get the atrubut value. however when you create a new attrubute you give it a Name AND a value
i can read the value of the attrubute but i can not figure out how to get the orginal name ( in this case the textboxs name)
I have no idea what you implying with the use xmlnode
|
|
|
|
|
Why not
<Match Name="TB_32_U" >1-North Carolina (32-2)</Match>
|
|
|
|