|
That's cool - I'll have a play with that over the weekend.
I'm glad that it isn't just me and this actually is quite hard!
Kind regards,
John.
|
|
|
|
|
hellow everyone
I want to create an excel file using c# meaning that I want to
write into the cell of the table of excel
can someone send me an example of
how I connect C# to excel?
thank u
|
|
|
|
|
barak160487 wrote: I want to create an excel file using c#
Perhaps you could generate a .csv [^] file which is readable by Excel?
/ravi
|
|
|
|
|
http://www.codeproject.com/office/csharp_excel.asp
http://www.thescripts.com/forum/thread224584.html
-- modified at 2:26 Friday 26th January, 2007
|
|
|
|
|
thank u it helped
|
|
|
|
|
On a usercontrol, is there an easy way to suspend all event handling on the control and all child controls? I don't want my event handling to keep firing as I set the form up, rather I just want to call a set of calculating/formatting functions just once in Load(), and then have all the events (which call the calculating/formatting functions) start firing. Right now I have an if statement in each event that ties to a boolean that I set when I want events to start working, but it seems like there might be an easier way.
Any suggestions?
|
|
|
|
|
How about using one method to remove the handlers and another to add. Then you're swichting them on and off in just two places.
i.e.
private void RemoveHandlers()
{
button1.Click -= new EventHandler(clickHandler);
----
}
private void AddHandlers()
{
button1.Click += new EventHandler(clickHandler);
----
}
|
|
|
|
|
I could look this up and figure it out, but what exactly is the difference between casting like (int) and Convert.ToInt32(); I am converting database columns and it throws an error if I use the first but is fine with the second.
I would like to know really what the differences are.
_____________________________________________________________________
Our developers never release
code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
Visit Me at GISDevCafe
|
|
|
|
|
A couple things:
An exception will not be thrown if the conversion of a numeric type results in a loss of precision (that is, the loss of some least significant digits). However, an exception will be thrown if the result is larger than can be represented by the particular conversion method's return value type.
and...
Some of the methods in this class take a parameter object that implements the IFormatProvider interface. This parameter can supply culture-specific formatting information to assist the conversion process.
Among other things, casting doesn't always work:
string foo="123";
int i=(int)foo; // That doesn't work
int j=Convert.ToInt32(foo); // This works.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
The latter part of your post actually was what I was hitting at, I am trying to understand why this behaviour occurs. I understand the who larger smaller conversion capabilities.
Thanx,
_____________________________________________________________________
Our developers never release
code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
Visit Me at GISDevCafe
|
|
|
|
|
There has to be an ISA relationship between the classes before casting works.
i.e. If int inherits string then the follwoing works:
string foo="123";
int i=(int)foo;
See the Int32 inheritance heirarchy:
System.Object
System.ValueType
System.Int32
|
|
|
|
|
I'll just add - you should use int.TryParse if you have any doubts about the conversion. This requires that you have a string, or that ToString gives you the representation you're hoping for.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Please can somebody give me a useful link od discription how to record and immediate show a stream from a webcam or from a camcorder. I have tried with windows media encoder but this way is too slow
thx
|
|
|
|
|
Firstly, wrong forum, this is for C# specific questions.
Unless you fork out big bucks for specialised hardware you're not going to be able to do this, trust me on this, I've tried, the smallest latency I managed was 2 seconds and someone who spent several years doing this kind of stuff was impressed with it.
I have no idea what I just said. But my intentions were sincere.
Poore Design
|
|
|
|
|
When I start my app, any relative paths ("subfolder\filename.exe") are referenced from the directory the exe is located in. After I select a file in the file open dialog though, the folder of the selected file is used instead. How can I reset the default starting path back to the folder where my app was launched from?
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
Well, you could use the GetCurrentDirectory[^] method to get the current directory just before you open the dialog, then call SetCurrentDirectory[^] afterward to reset it.
But, if your code is written properly, you should never have to worry about this. This means your code shoud be written to use fully qualified path names in all cases, and not rely, at all, on whatever the current directory is.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Would that be done by calling GetCurrentDirectory at app start and saving the value to combine for creating absolute paths at runtime, or is there a different static method provided in the framework that already does so?
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
YOu can get the path back to the directory that the .EXE was started from by using Application.StartupPath . If you have files in the same folder, or any subfolder, you can build your fully qualified names from that.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello,
Dave Kreskowiak wrote: YOu can get the path back to the directory that the .EXE was started from by using Application.StartupPath.
Is there a designtime support for that?
Means, all the other ways (apart from System.Inviroment.CurrentDirectory) brougt me an obscure path at design time.
I needed this for a costum designed property.
All the best,
Martin
|
|
|
|
|
The current directory doesn't, or more to the point, shouldn't, have any meaning at design time. All paths should be built upon well known Special Folder returns or designated application roots specified by some kind of application settings, and verified before use.
Martin# wrote: I needed this for a costum designed property
Curious - How so?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello Dave,
But if more then one person is working on an application it is often the case, that the pathes don't mach, and so you have to have a kind of hirarchy with the starting point exe-path.
I give you an example:
For this property, we made a property designer which has to have access to a database file.
During designtime the person is entering this property which shows a form with all the database informations. He than is able to modify or choose one element of the form, which is then copied (as a string) to the property and stored in the initializecomponent code.
Also the costumer is allowed to copy the application with all the xml, xsd, db, ..-Files wherever he whants.
Maybe we made some bad mistake, but I think we had no other solution for that.
But I very interested to your response.
All the best,
Martin
|
|
|
|
|
Martin# wrote: But if more then one person is working on an application it is often the case, that the pathes don't mach, and so you have to have a kind of hirarchy with the starting point exe-path.
I have no idea what you're talking about. It doesn't matter how many people are using the same application. The .EXE path is always returned by Application.StartupPath. CurrentDirectory is not reliable to return that path.
Martin# wrote: For this property, we made a property designer which has to have access to a database file.
During designtime the person is entering this property which shows a form with all the database informations. He than is able to modify or choose one element of the form, which is then copied (as a string) to the property and stored in the initializecomponent code.
OK. So what? The path is stored in the startup code, preferably as a fully qualified or relative path, such as "\subfolder\file.xml".
Martin# wrote: Also the costumer is allowed to copy the application with all the xml, xsd, db, ..-Files wherever he whants.
OK. So your application builds the absolute path from Application.StartupPath and the relative path stored somewhere:
Dim path As String = Path.Combine(Application.StartupPath, "\subfolder.file.xml")
This will hold true and work no matter what folder the customer copies the .EXE file and subfolders/files to.
THere is just about never a reason to depend on CurrentDirectory unless you're writing some kind of commandline utility.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello Dave,
First, thank you for your time again!
I think there was a lot of misunderstanding from my side regarding to your words (like: fully qualified), because of my poor english and/or my programing skills! I actually was thinking that you don't like any kind of combining pathes for finding the exe path. Thats why I made that kind of long(useless) explination try before.
But I think there is one very important point for me which was not answered correctly, or maybe it was a wrong explination from my side.
I wrote: Is there a designtime support for that?
Means, all the other ways (apart from System.Inviroment.CurrentDirectory) brougt me an obscure path at design time.
Dave Kreskowiak wrote:
OK. So your application builds the absolute path from Application.StartupPath and the relative path stored somewhere:
Dim path As String = Path.Combine(Application.StartupPath, "\subfolder.file.xml")
This will hold true and work no matter what folder the customer copies the .EXE file and subfolders/files to.
Ok. But I tested it for my designtime needs, and it is not working!
The problem is that most methods or properties returning pathes like: "C:\Programe\Microsoft....\VS2003\Common7\IDE", instead of: "C:\MyFolder\...".
"System.Enviroment.CurrentDirectory" is the only property I found which works during run- and designtime in the same way.
Dave Kreskowiak wrote: THere is just about never a reason to depend on CurrentDirectory unless you're writing some kind of commandline utility.
Please let me know if this is still your last word, after my try to explain my problem a little better.
So, again thanks for your time and patience!
All the best,
Martin
|
|
|
|
|
Hello,
If you whant to have the path to the exe file, you should use:
System.Environment.CurrentDirectory
All the best,
Martin
|
|
|
|
|
That doesn't necessarily return the directory the .EXE is in. If the .EXE file is double-clicked, it will most likely be the corret folder, but if it was launched from a shortcut, the shortcut can specify a different directory than the one the .EXE is in.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|