|
Call it recursively?
|
|
|
|
|
One way to do it is to add using System.Windows.Forms; to the top and call Application.Restart(); . You may need to add the reference: "System.Windows.Forms.dll" to your project.
I'm not sure of the implications if there are any for using it in a console application.
modified on Tuesday, August 31, 2010 1:54 AM
|
|
|
|
|
Hello,
Does anyone know for some tools which can export merged cells from excel to CSV. For example CSV should look's like this part:
Godina,Mjesec,"AKTIVA; Neto strana aktiva; Strana aktiva","AKTIVA; Neto strana aktiva; Strana pasiva","AKTIVA; Neto strana aktiva","AKTIVA; Domaći krediti; Potraživanja od centralne vlade (neto)","AKTIVA; Domaći krediti; Potraživanja od kantona i općina","AKTIVA; Domaći krediti; Potraživanja od nefinansijskih preduzeća","AKTIVA; Domaći krediti; Potraživanja od privatnog sektora","AKTIVA; Domaći krediti","AKTIVA; Aktiva Ukupno","PASIVA; Novčana masa (M2); Novac (M1); Gotovina izvan banaka","PASIVA; Novčana masa (M2); Novac (M1); Depoziti po viđenju u domaćoj valuti","PASIVA; Novčana masa (M2); Novac (M1)","PASIVA; Novčana masa (M2); Kvazi novac (QM); Depoziti po viđenju u stranoj valuti","PASIVA; Novčana masa (M2); Kvazi novac (QM); Oročeni i štedni dep. u domaćoj valuti","PASIVA; Novčana masa (M2); Kvazi novac (QM); Oročeni i štedni dep. u stranoj valuti","PASIVA; Novčana masa (M2); Kvazi novac (QM)","PASIVA; Novčana masa (M2)","PASIVA; Obveznice i instrumenti tržišta novca","PASIVA; Ograničeni depoziti","PASIVA; Protustavke fondova","PASIVA; Vladini fondovi za kreditiranje","PASIVA; Ostale stavke (neto)","PASIVA; Pasiva Ukupno"
Fields are separated with commas "," but "tree" structure for each field is delimited with ; .
Godina
Mjesec
AKTIVA
-+Neto strana aktiva
-+--Strana aktiva
-+--Strana pasiva
-+Domaći krediti
-+--Potraživanja od centralne vlade (neto)
-+--Potraživanja od kantona i općina
.....
You can find example of such table on url: http://www.cbbh.ba/index.php?id=33&lang=bs&table=monetarni_pregled[^]
|
|
|
|
|
You might take a look at FileHelpers v2.0 - Delimited (CSV) or Fixed Data Import/Export Framework[^].
The library has the ability to deal with both xls and csv files/values.
Of course you will have to decide for yourself if it will solve your problem.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thanks I will take a look on it, it seems to me as very interesting library.
Best regards,
Fehim.
|
|
|
|
|
Hello,
I want to convert datagridview to excell.
I need to create a button that will do it.
Every time that i click on it , it will create a new worksheet (in a specified workboox- or a file).
Also i need it to autoresize the columns width (as in the datagrid) and change the background of the headercells to some color (doesn't matter which).
How can i do it?
|
|
|
|
|
You can try to do that with:
http://www.devexpress.com[^] components which are not free but they worth.
You can export datagrid in excel/pdf/html/xml ... with few lines of code.
In order that you want to use "native" datagridview, you can try to save underlaying dataset to excel using JET drivers or ODBC connection.
Here is how you can made connection:
public OleDbConnection Conn
{
get {
if (conn == null)
//conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties=Excel 8.0;");
conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + ";Extended Properties=Excel 12.0;");
return conn;
}
}
Best regards,
Fehim.
|
|
|
|
|
I didn't understood so much what does it mean using the connection...where do i write the sql query etc. And i need it to autoresize the columns with and copy the header cells too (with background in the header row (cells).
|
|
|
|
|
on this way you can't resize columns , for that purpose you must use excel com objects. There is a lot of resources on internet. Did you look on this one: Simple Excel Automation using C#[^]
|
|
|
|
|
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
myDataGrid.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
I know nothing , I know nothing ...
|
|
|
|
|
|
Take a look at Single Instance Application in C#[^].
There are several other articles about this on the web, I found the one above and loads more by googling single instance c#.
Give it a go yourself if the one given is not good for you.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
To add to Henrys' comment: Don't post your email address, unless you really like spam!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Well spotted. I didn't notice that amongst all the beautifully formatted text.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
i thought i didnt post my email.................where did u saw it....so zat i can remove it.............tnx 4 z help
|
|
|
|
|
In your original post:
matiIsGreat wrote: please ppls help me with this problem.............I made a program with C# and prepare a set up to be installed to the user computer...........but after u install it u can open many instances of the program @ one time............so how can i make it to be opened only 1 @ a time......if i didnt make that my buyer is not going to buy me.......so plz help me(my email is getXXXX@XXXXXXil.fm )...thank you all
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
tnx dude..........i didnt thought of zat......i didnt know hw my eyes worked...loll
|
|
|
|
|
To ensure a single instance of an application, you can try something like the following:
bool createdNew = true;
using (Mutex mutex = new Mutex(true, "MyApplicationName", out createdNew))
{
if (createdNew)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
Place the following code in the main entry point for your application. With VS 2005, you would place this in the Program.cs.
|
|
|
|
|
|
Easy peasy:
If your form load event:
Process process = Process.GetCurrentProcess();
Process[] processes = Process.GetProcessesByName(process.ProcessName);
if (processes.Length != 1)
{
Close();
}
If you had Googled it, you would have found a class to do it on this very forum...
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
This technique works, but copying the .EXE to another filename will defeat this solution. Granted, it's not going to be very common "work around" to get a second or third copy running, but, I think there are better methods to solving the problem than this that are more secure.
|
|
|
|
|
on a single PC? or on different machines?
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
for now i just wanted only 4 one pc...........it would also b better if u told me on a different machine....tnx dude
|
|
|
|
|
eye nodding understanded
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
I have a requirement to connect a network drive, once it gets disconnected.
I am using WNetAddConnection2A() API of mpr.dll. It works fine for a console/windows application.
When I tried to use the same code in windows service, it’s unable to connect the drive.
WNetAddConnection2A() returns an int value. A non zero value is a failure and zero is a success.
In windows service it returns zero, still drive does not get mapped/connected.
int result = WNetAddConnection2A(n, password, username, dwFlags);
In ServiceProcessInstaller we have 4 types of Account. I tried with all of them and got the below return value from WNetAddConnection2A().
1- LocalService : 1312
2- NetworkService : 0 (Success, Still drive is not mapped).
3- LocalSystem : 1312
4- User : 0 (Success, Still drive is not mapped).
Error 1312: A specified logon session does not exist. It may already have been terminated.
Any help in this regard is appreciated. Also would like to know what kind of Account should I use.
Praveen Raghuvanshi
Software Engineer,
India.
|
|
|
|