|
They are currently returning the correct Row/Column. When I debug I get the correct row. I use the same lastUsedRow and lastUsedColumn to do the calculations currently. See below code. Difference is that I write the calculated values to a selected Cell. See below extract for the calculations etc.
int lastUsedRow = objSheet.Cells.SpecialCells
(Excel.XlCellType.xlCellTypeLastCell, Type.Missing).Row;
int lastUsedColumn = objSheet.Cells.SpecialCells
(Excel.XlCellType.xlCellTypeLastCell,Type.Missing).Column;
objRange = objSheet.get_Range("D1",
System.Reflection.Missing.Value);
objRange.Value2 = "Total of Level 1";
objRange.Font.Bold = true;
objRange.Font.Italic = true;
objRange.Font.ColorIndex = "5";
objRange = objSheet.get_Range("D2",
System.Reflection.Missing.Value);
objRange.Value2 = "Total of Level 2";
objRange.Font.Bold = true;
objRange.Font.Italic = true;
objRange.Font.ColorIndex = "5";
objRange = objSheet.get_Range("F1",
System.Reflection.Missing.Value);
objRange.Value2 = "Difference (Level1 - Level2)";
objRange.Font.ColorIndex = "5";
objRange.Font.Bold = true;
objRange.Font.Italic = true;
objRange = objSheet.get_Range("E1",
System.Reflection.Missing.Value);
objRange.Formula = string.Format("=SUM(J4:J{0}", lastUsedRow);
objRange.FormulaHidden = true;
objRange.Calculate();
objRange.Font.Bold = true;
objRange.Font.ColorIndex = "5";
objRange.HorizontalAlignment = XlHAlign.xlHAlignLeft;
objRange = objSheet.get_Range("E2",
System.Reflection.Missing.Value);
objRange.Formula = string.Format("=SUM(K4:K{0}", lastUsedRow);
objRange.FormulaHidden = true;
objRange.Calculate();
objRange.Font.Bold = true;
objRange.Font.ColorIndex = "5";
objRange.HorizontalAlignment = XlHAlign.xlHAlignLeft;
objRange = objSheet.get_Range("F2",
System.Reflection.Missing.Value);
objRange.Formula = "=SUM(E1-E2)";
objRange.FormulaHidden = true;
objRange.Calculate();
objRange.Font.Bold = true;
objRange.Font.Italic = true;
objRange.Font.ColorIndex = "3";
objRange.HorizontalAlignment = XlHAlign.xlHAlignLeft;
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
My app make cross-thread calls to many main form controls. I have disable CheckForIllegalCrossThreadCalls by set it to false, without using any Invoke method for the cross-thread control update. And the app is running fine so far.
My question is: Is it okay to turn off CheckForIllegalCrossThreadCalls, for this cross-thread control update? What are the negative effects?
Thanks.
Kelvin
|
|
|
|
|
8kelvin wrote: What are the negative effects?
It is only for debugging and will only work when the debugger is attached. Here is what MSDN says,
Note that illegal cross-thread calls will always raise an exception when an application is started outside the debugger.
|
|
|
|
|
Hi Navaneeth, thank for the prompt reply.
But the app that i mentioned already installed in other pc, and it run without any problem too.
Kelvin
|
|
|
|
|
8kelvin wrote: What are the negative effects?
If you've seen Ghostbusters, I'm sure your aware what happens when you cross the threads. It is bad and kittens maybe hurt. You don't hate kittens do you?
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
8kelvin wrote: Is it okay to turn off CheckForIllegalCrossThreadCalls
Not at all.
Your app will not work reliably if you do.
That property should never have been introduced, they created it when .NET (evolving from 1.1 to 2.0) got strict on cross-thread checking, so they thought it was wise to provide a way to continue doing things the wrong way.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi all,
Is it possible to drag and drop cell value from one cell to another cell in the same datagridview?
if yes then how it is possible?
thanks
|
|
|
|
|
|
hi all,
does any one know how to find a com port is default or not in C#?
|
|
|
|
|
hi,
how do find out what's your 'default com port' in general (e.g. in windows)? Is there anything I don't know?
bye
|
|
|
|
|
Hi,
AFAIK there isn't a "default COM port" at the Windows level.
What may exist is a default port for some app, say a terminal server.
But then the notion only exists within that app, and how it gets selected is depending on that app.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi,
I am developing a contact book using C# WPF and a textbox can contain contacts as the user has added from the existing contact book. The textbox showing the selected contacts will looks like: "John; Peter; Tom;".
The user can add new names to the textbox but if he want to edit an existing name that name shall be highlight and not be able to edit the existing name, just like Microsoft Outlook when you send a new email and try to modify a email address added from contact list.
How do I adjust my textbox so it get this behavior?
Example:
The user has added the following contacts to the textbox. "John; Peter; Tom;"
The problem is how do I prohibit the user to modify contact "John" like "John123456789; Peter; Tom;"
If he starts modify contact John the textbox shall contains "123456789; Peter; Tom;" instead.
Regards
Magnus
|
|
|
|
|
I'm not sure of any WPF relevance but I would namage the position of the caret in the text (little flashing verticle bar) and depenting on the position and the relationship to the word and ; in the text manage the selected property of the text.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello,
Currently I am working on creating a drawing editor.
I am unable to find the function which can draw an arc using a mouse like a line by using the RevesibleLine function.
Thanks in Advance.
MR. Bats
|
|
|
|
|
I don't think there is one, there's only a method for drawing beziers, which means your user needs to define the individual points. To draw and have a steady arc come out, requires code to create a custom path, I beleive.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
|
How do i get to know the exe path of any random executable in C#?
|
|
|
|
|
By random executable, do you mean the app has to pick one at random with no user input? Use the classes in System.IO (DirectoryInfo, FileInfo for starters) to create a list of EXE files, then pick one at random.
|
|
|
|
|
Thank you. I got the answer.it should be something like this
RegistryKey objKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Installer\Assemblies");
string regfilepath = "";
if (objKey != null)
{
foreach (string Keyname in objKey.GetSubKeyNames())
{
if (Keyname.IndexOf("ApplicationName.exe") > 0)
{
regfilepath = Keyname;
break;
}
}
}
|
|
|
|
|
I'm working on learning C# using VS2008, and have started a project for various mathematical functions. Everything was working fine, until I tried to separate the file into individual classes. In order to do this, I created a new class (.cs file) for the calculations. Within these classes I needed to reference text boxes found in the Window1() class, so I added this to the Calculations() class:
Window1 w = new Window1();
along with it's twin in the Window1() class:
Calculations c = new Calculations();
Now every time I try to compile and run the program, it returns a System.StackOverflowException error and crashes immediately.
From what I've been able to find courtesy of google, this is because of a redundant loop, but I don't understand where this would be. Debugging the code points to the first class definition above, but as I understand it all that does is make the Calculator() class able to reference the Window1() class.
Thanks for your help!
|
|
|
|
|
Where did you add these lines, and why? In the constructor? If yes, then it's no surprise your app crashes - your Calculations instance creates a Window, which creates a Calculations instance, and so on, and then, Wham!
You have to use a better way to pass your form data to Calculations. In fact, creating a new instance of Window1 in Calculations does just that - creates a new instance; you will not be able to access your form's data from that instance.
|
|
|
|
|
Okay, I had a whole longer question in here, but I answered it myself (well, I figured it out and once I did, your explanation made sense...I was placing one new Window1() statement in the Calculations class and vide versa rather than individual ones in each method of the given class).
Thanks for the help
modified on Wednesday, March 18, 2009 9:45 AM
|
|
|
|
|
Actually to clarify (in case anyone searches this later with the same question, I ended up using ref to pass get the result I needed. Now everything works beautifully.
|
|
|
|
|
please give detailes about system level projects
|
|
|
|
|
I hate to say it, but the quality of this forum drops to zero every day at around this time. What country starts to provide a lot of posts at this time ?
You're an idiot. Your question makes no sense, it can't be answered. What do you mean by 'system level' ? Why is google broken where you live ? Why don't you own any books ? What are you asking for, and why ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|