|
There are some articles here on Codeproject which cover this topic. Simply search for "single instance".
www.troschuetz.de
|
|
|
|
|
I've found several that talk about how to ensure you're running a single instance. But I haven't been able to work any of those into loading the new file. :/
|
|
|
|
|
You may be able to do something like this:
<br />
void Main(string[] arguments)<br />
{<br />
if (IsFirstInstance())<br />
{<br />
StartAndSubscribeToStartEvents(arguments);<br />
}<br />
else<br />
{<br />
PublishStartEvent(arguments);<br />
}<br />
}<br />
The IsFirstInstance() method would use one of the mechanisms floating around for determining whether an instance of the application is the only instance running. The StartAndSubscribeToOpenEvents() would, obviously, start the application as normal. It would also create a subscription to some kind of event that will be published whenever a subsequent instance of the application is started. The event could take the form of a MSMQ message, a method call using .NET remoting, windows messages, shared memory, raw sockets--whatever your favorite IPC mechanism may be. The PublishStartEvents() method would be invoked whenver a subsequent instance of the application is started. It publishes the start event, passing any arguments the instance may be given (e.g. the path to the log file). The primary instance then gets notified of the event and can do whatever it likes with the event data (e.g. open the log itself).
Just an idea.
-Phil
|
|
|
|
|
Hi all!
I have DataGridView whose sourse I set to a datatable with 4 columns
containing data. I then remove a column, create a DataGridViewComboBoxColumn and insert this into the same location as the column that was removed. I want to set as the selected value in the combo box of every cell in the DataGridView a specific value I have stored in the column of the datable that I removed in the DataGridView.
How can I set a value in a cell of the DataGridView that contains a DataGridViewComboBoxColumn?
Thanks for your help,
~~Elvia
|
|
|
|
|
I tried dataGridView1.Rows["RowName"].Cells["ColumnName"].Value = "1"; but it doesn’t work.
|
|
|
|
|
hi there
first use findcontrol function for getting the control combobox then set its value.
(controltype)dataGridView1.Rows["RowName"].Cells["ColumnName"].findcontrol("ControlID").value = "1"
|
|
|
|
|
Hi Goyal,
Thanks a lot for the suggestion. I tried it, but it doesn't work in my case. I'm programming a Window application form. I'm using the namespace System.Windows.Forms and as far as I saw FindControl is for System.Web.UI . I think the solution is the one you gave me, but for web applications.
So far I have been looking for something similar to your suggestion for a windows form, but I haven't succedded. Do you know another solution?
Thank you,
Elvia
|
|
|
|
|
Hi everybody!
I have added items to the DataGridViewComboBoxColumn and the value that I want to set is one of the values in the items list. This is my code:
DataGridViewComboBoxColumn cb = new DataGridViewComboBoxColumn();
cb = CreateComboBoxColumn("Category");
cb.Items.AddRange(new string[] { "Mr.", "Ms.", "Mrs.", "Dr." });
dataGridView.Columns.Insert(1, cb);
dataGridView.Rows[0].Cells[1].Value = "Mr.";
I want to see as the selected value in the combobox “Mr.”. Once I load the form the combobox doesn’t show a selected value. I have to drop the combobox to see the items.
Any suggestion is very welcome,
Elvia
|
|
|
|
|
Hi,
I have been debugging my windows application. I have found that the code in the previous post is working as I expected, because I see the variable in the Watch window.
I have the code of the previous post in the Load() method of the form class (FrmTestCases.cs) that has my DataGridView.
But when the debugger leaves the file that has this code (FrmTestCases.cs) to return to the file that called this code (FrmExplorer.cs), the value that I set in that cell by the code is lost and set automatically to null.
When the value was lost I set it in this watch window and the ComboxBox selected the value I set.
I don't know whether the problem is because I removed and then added this column (see the first post). At the end of the Load() method I have this line: dataGridView.AutoGenerateColumns = false; if I don't use it, the column that I removed appears again. Any idea about why the value of the DataGridComboBoxColumn is changed to null automatically and how to solve it?
Best Regards,
Elvia
|
|
|
|
|
I have a situation in which i have to pass reference to a form at run time. The two conditions which must be followed the project are :-
1. The calling (parent) form will be dynamic and the called (child) form will be a static one.
2. The called form may return a value to the calling form.
I have studied about and also explored abt in on net but the response i m getting abt it is that, i cannot refer to parent form's properties/methods/variables from child form untill i have a reference to it and i cannt get reference of it (parent form) since its referenced on run time therefore i dont know what will be the parent form and its variables.
Sample code : -
Instance of Child form created and showed.
frmList list = new frmList();
list.frmFromName = this;
list.Show();
Passing a value via the child form instance to parent form....
public Form frmFromName=new Form();
frmFromName.nMasterId = Convert.ToInt32(dataGridView1.Rows[nRowIndex].Cells[0].Value);
abhinav
|
|
|
|
|
|
Hello, I am very much a beginner coder - 2nd week!
I would like to create a custom tooltip. The tooltip contains an icon, a title, some additional text and a gradient background that is semi-transparent.
All help is greatly appreciated.
|
|
|
|
|
You could subclass from Tooltip , set the OwnerDrawn property to true and handle the Draw event.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Hi all,
Can anybody help for my requirement ? . I will appreciate that. My requirement is as follows.
1. I have a data in excel sheet . The example data what I have is like this
2004 Sales 2005 Sales 2006 Sales 2007 Sales
1 1 5 2
2 20 10 4
3 30 15 6
4 40 20 8
5 50 25 10
6 60 30 12
7 70 35 14
8 80 40 16
9 90 45 18
I wanted to generate the charts for the columns 2004sales and 2005 sales seperately and 2004 sales and 2006 sales and 2004 sales and 2007 sales .
All the charts I need to generate seperately . and put them on excel sheet .I wanted to use C# code . The code what I have is as follows.
object missing = System.Reflection.Missing.Value;
Excel.Workbook workBookObject = null;
Excel.Range oResizeRange = null;
Excel.Worksheet excelWorkSheet = null;
Excel.Worksheets excelSheets = null;
Excel.Application excelApp = null;
excelApp.Visible = true;
string workbookPath = "D:/osxpasql12.xls";
workBookObject = excelApp.Workbooks.Open(workbookPath,
0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "",
true, false, 0, true, false, false);
//excelSheets = excelWorkbook.Worksheets;
//excelWorksheet = (Excel.Worksheet)excelSheets.get_Item("osxpasql12");
Excel.Chart xlChart = (Excel.Chart)workBookObject.Charts.Add(missing, missing, missing, missing);
xlChart.ChartType = Excel.XlChartType.xlLineMarkers;
Excel._Chart oChart = (Excel._Chart)workBookObject.Charts.Add(missing,missing,missing,missing);
//Excel._Chart oChart = (Excel._Chart)workBookObject.Charts.Add( missing, missing, missing, missing );
oChart.ChartWizard( oResizeRange, Excel.XlChartType.xl3DColumn, missing, Excel.XlRowCol.xlColumns, missing, missing, missing, missing, missing, missing, missing );
---------------------------------------------------------------------------------------------------------
with the above code its taking the range . I need a solution where we can read individual columns and generate charts individually.
Any solutions please help me.
Thanks in advance .. Aparna
Aparna
|
|
|
|
|
I'm new to C# and am struggling to find a solution to sending a byte array in a SOAP message. I've used the BinaryFormatter to create the byte array but that doesn't appear to be something I would use to send via a SOAP message. We did this from Java as a test case and I've included the below message that we are trying to create as an example.
Any help would be greatly appreciated.
Thanks!
- <soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <soap-env:body>
- <ns1:getemployeesforplantbyteresponse xmlns:ns1="http://mycompany/service/ws/EmployeeService.wsdl" soap-env:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/">
<return xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:base64">PEVtcGxveWVlTGlzdD4KICA8ZW1wbG95ZWVzPgogICAgPEVtcGxveWVlPgogICAgICA8Zmlyc3ROYW1lPk1hcmNpYTwvZmlyc3ROYW1lPgogICAgICA8bGFzdE5hbWU+Qm9nbmVyPC9sYXN0TmFtZT4KICAgICAgPGRlcHRSZXB0VG8+MDE4ODQ8L2RlcHRSZXB0VG8+CiAgICAgIDxkZXB0U3VmZml4PjA8L2RlcHRTdWZmaXg+CiAgICA8L0VtcGxveWVlPgogIDwvZW1wbG95ZWVzPgo8L0VtcGxveWVlTGlzdD4=
|
|
|
|
|
I have a text file that I am scanning through. The is a date in the format mmddyy(no slashes). How to I convert this into a datetime structure? datetime dtex = new datetime(mm,dd,yy)? Thanx in advance!
Jude
|
|
|
|
|
|
I get the following error with DateTime.Parse :
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: String was not recognized as a valid DateTime.
In the debugger, the string strBDate has the value of 01011900.
Jude
|
|
|
|
|
TheJudeDude wrote: strBDate has the value of 01011900.
String was not recognized as a valid DateTime.
Which means you need to parse it yourself.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
got it! Thanx!
Common sense...the least common of the senses used
Jude
|
|
|
|
|
|
with this code i copy from one DBF to Another DBF.
but how can i Copy DBF file to MDB
this exapple is working fine
string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + APP_PATH + "\\TMP ;Extended Properties=dBase IV";
OleDbConnection DBConnection = new OleDbConnection(ConnectionString );
InsertQuery = "INSERT into "+APP_PATH+"\\TMP\\"+DBFfile.ToString()+" Select * from "+APP_PATH+"\\"+DBFfile.ToString();
OleDbCommand InsertCommand = new OleDbCommand(InsertQuery,DBConnection);
DBConnection.Open();
InsertCommand .ExecuteReader();
DBConnection.Close();
this one i need help, do i have to make a connection to DBF file ?
string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Application.StartupPath+"\\MainDB.mdb";
OleDbConnection DBConnection = new OleDbConnection(ConnectionString);
string InsertQuery = "INSERT into GNDSALE Select * from D:\\GNDSALE.DBF ";
OleDbCommand InsertCommand = new OleDbCommand(InsertQuery,DBConnection);
DBConnection.Open();
InsertCommand.ExecuteReader();
DBConnection.Close();
-- modified at 14:18 Wednesday 3rd May, 2006
|
|
|
|
|
Hello everyone,
i'm working on a program that uses Crystal Reports.
How can i print the report without using the CrystalReportViewer control?
The only way i know to print a report is using that component and hit the print button on it. Is there another way without see the preview of the report?
Thanks in advance.
Enrico
VentoEngine corp.
Program your life ^^
|
|
|
|
|
Hi
No problem with CrystalReportViewer for print the report.
just use following code to print.
CrystalReport1.PrintToPrinter(no.of copies,bool collated,start page,end page);
|
|
|
|
|
HI,
Can anyone tell me how to get the total physical memory(The one displayed on the task manager) and the system cache info too.
|
|
|
|