|
Hi,
Thanks Stanimir_Stoyanov and J4amieC.
I got it right already with your suggestions. Cheers.
Regards,
Chua Wen Ching
Visit us at http://www.necoders.com
|
|
|
|
|
Hi.
I have a list view with about 4000 items (with 7 subitems, too) and I'd like to 'export', ie. save all the data, to a tab-separated file, so the data can be reloaded later. The problem is, that the saving and loading process using, for example:
(Save)
(...)
foreach(ListViewItem lvi in this.listView1.Items)
{
string line = "";
line += lvi.Text;
for(int i=1;i
|
|
|
|
|
Hi, what you want to do is called serialization. Serialization is saving an object's state to a stream so its state can be transported or saved and later restored.
You suggested a tab separated text file, which is nice since the file is easily read and understood by other applications, however binary files are faster. If format don't mattter to you, I would suggest binary format.
BinaryFormatter.Serialize Method is the method you use for binary serialization. The problem will be for you that a listview control or ListViewItemCollection object do not support serialization. To be able to serialize an object, the object's class needs to be either marked with the Serializable attribute or implement the ISerializable interface.
The class ArrayList however is marked Serializable attribute and it's pretty easy to construct an arraylist from a listview control.
Good luck and feel free to check my C# blog,
Patric
|
|
|
|
|
i would like to print directly without preview the report.
This is the code that i have written.
//BEGIN CODE
// Declare the variables
TableLogOnInfo logOnInfo = new TableLogOnInfo ();
int i = 0;
ReportDocument report = new ReportDocument();
report.Load("EtatEcheancier.rpt");
Parametres.Configuration.Database mainD =
Parametres.Configuration.Database.MainDatabase;
while(i <= (report.Database.Tables.Count - 1))
{
logOnInfo = report.Database.Tables[i].LogOnInfo;
logOnInfo.ConnectionInfo.ServerName = mainD.Serveur;
logOnInfo.ConnectionInfo.DatabaseName = mainD.BaseDonnees;
logOnInfo.ConnectionInfo.UserID = mainD.Utilisateur;
logOnInfo.ConnectionInfo.Password = mainD.MotDePasse;
report.Database.Tables[i].ApplyLogOnInfo(logOnInfo);
i++;
}
report.PrintToPrinter(1, true, 0, 0);
//END CODE
it doesn't work. it opens the save window. and if i click on cancel an InternalException is returned
thank you for your help
|
|
|
|
|
^
Hi,
since I have two monitors now, and my desktop is expanded across both,
I wanted an screensaver for both monitors, just showing an image.
The screensaver needs to strecth the image across both screens.
With the help of the code from the CP screensaver I got it working.
Only it keeps using more memory every time the image changes.
I think it's a simple problem not releasing the image, but I a bit of a noob.
Can someone help me on my way?
Grtz, Steven.
############################################################
...
// holder for bitmaps in folder:
private long maxImageIndex = 0;
private long myBitmapIndex = 0;
private string[] myBitmapStrings;
// temp holder for bitmap:
private Bitmap myBitmap;
...
private void loadPicture()
{
try
{
myBitmap = new Bitmap(Image.FromFile(myBitmapStrings[myBitmapIndex]), rcScreen.Width, rcScreen.Height);
this.pictureBox1.Image = myBitmap;
Console.WriteLine("Loaded image " + myBitmapIndex + ": " + myBitmapStrings[myBitmapIndex]);
}
catch(Exception e)
{
Console.WriteLine("There has been an error loading the picture: " + e.Message);
}
}
...
############################################################
|
|
|
|
|
Have you called Dispose on your bitmap when you're done?
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Hi Matt,
thx for your input
What I have now:
I use an private Bitmap.
this is filled with an scaled Image.FromFile() when I load a picture.
This Bitmap is then used as picture in my picturebox.
When I reload I cannot dispose of the bitmap, if I do I get:
######
Found 23 jpg images in directory C:\Documents and Settings\Steven\My Documents\MyScreensaver
There has been an error loading the picture: Object reference not set to an instance of an object.
The program '[480] myScreenSaver.exe' has exited with code 0 (0x0).
######
I do dispose of the Image.FromFile(), but that doesn't help.
On intervals I change the image, getting the filename from an hash?( -> mystrings[])
And this increases the used memory by 10MB or so.
Is this the right way to show an image as screensaver?
|
|
|
|
|
ah,
I did it!
It was because the picturebox needed the image to be there.
And so I couldn't dispose it.
Now I have this, and I think this works.
#####
private void loadPicture()
{
try
{
myImage = Image.FromFile(myBitmapStrings[myBitmapIndex]);
this.Invalidate();
Console.WriteLine("Loaded image " + myBitmapIndex + ": " + myBitmapStrings[myBitmapIndex]);
}
catch(Exception e)
{
Console.WriteLine("There has been an error loading the picture: " + e.Message);
}
}
protected override void OnPaint(PaintEventArgs e)
{
Graphics dc = e.Graphics;
dc.DrawImage(myImage, 0, 0, rcScreen.Width, rcScreen.Height);
myImage.Dispose();
base.OnPaint(e);
}
######
Now I can use dispose.
I am going to test this.....
Thx everyone!
|
|
|
|
|
Hi,
I was wondering how to get foll. explorer like controls : (in order of preference)
a) Launch Explorer(C:\) in WinXP. Do not have any of the side panes like "search" or "folder" treeview opened. Close all such panes. On yr LHS we see some sections named "Files and Folder Tasks", "Other Places", etc. These drawer like controls have circular buttons with double-arrows(>> pointing vertically). I wish to have this kind of a control, without color. If I can also get the sliding drawer like functionality, much better - nothing like it.
b) The "Go" button with green arrow on explorer's address taskbar. I guess its the same as (a), but if not, pls let me know.
There are many other controls which I sometimes see in Windows' own GUI, and wish to have them as part of my Windows Forms. Is there a standard way to get these controls ? Does Microsoft make them publicly usable/accessible somewhere ?
Thanks.
As a part of cost cutting, the light at the end of the tunnel has been switched off !!
|
|
|
|
|
Search code project for the first one. Second one is a simple image button. No MS doesn't have the collapsible panel controls available, CP is best place to find these for free.
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Hello every one please help meeeeeee,
At the movemet i'm involving into analyze phase of a web base project Management system which is going to develop by using c#.and i'm using rational XDE for the part of uml design.but i 'm new to rational XDE.so can any body give me a sample application which is developed by using XDE and ebook or chm file as a guide.
And also i need a sample guide material for model a system by using uml notations.
Thanks
|
|
|
|
|
|
Thanks a lot for the quick response.i have go through that and i want some thing more detail than that.somthing like step by step modeling of a paricular application.cas some download links r not active in IBM site.
So if some one have more detail about how a dot net application build on rational XDE.Please let me know soon.
Amal
|
|
|
|
|
Hi
I'm writing a C# application that has links to run other applications that i've also written in C#. The problem is when I close one of these sub-applications, the main application which called them is also closed.
In the sub-application, the OnClosing method executes the Application.Exit.
How to rewrite the exit function of the sub-application to avoid closing the main one?
I'd be very gratefult if u answer my question as soon as possible.
thanx alot
|
|
|
|
|
Anonymous wrote:
application that has links to run other applications
What exactly do you mean here? I'm getting the feeling that you interchange the terms form and application.?
If so, leaving out the Application.Exit should do the job.
www.troschuetz.de
|
|
|
|
|
if your sub application has a dispose method can't you just, instead of application.exit() put in this.dispose() ??
|
|
|
|
|
I'm with Stefan on this one. Closing an application that your application launched will not affect the parent app. I also think you're using Form and Application interchangably.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
well.. I'm sorry what I said wasn't clear. the application I'm talking about is something like a package that has to provide more than one tool. This package launches two other applications: an editor application and a wizard (the wizard consists of several forms that call each other in a certain sequence to accomplish its task).
I can't make the package MDIParent of the the other two applciations since the editor is already MDIParent and can't be a prent and child at the same time.
Although the editor application uses Application.Exit() when it's closed, the launching package is not affected, but closing the wizard ends the application. I'll try to use this.Dispose() to exit the wizard.
thanx for everything
|
|
|
|
|
I have two functions:
void foo(params someRefObject[] arr);
and
void foo(someRefType o);
When I call foo(someRefInstance) , which of them will be called? And what about foo(null) ?
Thanks.
|
|
|
|
|
I did some checks, and I got the following:
foo(null) won't compile, but foo((someRefType)null) , and foo(someRefInstance) will both call foo(someRefType o) .
I wonder if it will be the same in the next version of .Net.
Yaakov
|
|
|
|
|
What are the differences, if any?
Thanks,
Yaakov
|
|
|
|
|
When using out , the parameter needn't be initialized before being passed to into the method, and it must be assigned a value before the method exits.
If you need more info, I'd suggest looking in the docs[^].
Charlie
if(!curlies){ return; }
|
|
|
|
|
Thanks a lot.
Actually, I've read rhe docs before, but I didn't notice this difference.
Yaakov.
|
|
|
|
|
int a,b,c,d,e,f,g = foo(out a, out b, out c, out d, out e, out f);
vs
int a,b,c,d,e,f;
a=b=c=d=e=f=0;
int g = foo(ref a, ref b, ref c, ref d, ref e, ref f);
so, about 2 lines :->
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|