|
If possible, you can add another constructor and those values there. The desingner will ( ) allways use the default constuctor, else you can check the DesignTime property, but that can be a bit over the top for something small.
Hope this helps
|
|
|
|
|
Hi leppie,
Thanks,
leppie wrote:
add another constructor
That is a great Idea. It works.
But, (in my project) this will require code modification in a lot of places.
Actually, I have a base form and around 40 forms derived from this base form.
It would be wonderful, if I could put some code in the Base Form constructor
itself, instead of modifying the constructor of all derived forms.
But I liked your Idea, and I will keep it as a last option.
leppie wrote:
check the DesignTime property
I had tried this before, but this property always returns false.
Can you put some more light into this (how to use the DesignTime property).
Thanks,
Firoz
|
|
|
|
|
so this does not work?
public MyClass()
{
if (DesignMode)
{
}
else
{
}
}
Note you can never check for this yourself...
Hope this helps
|
|
|
|
|
leppie wrote:
so this does not work?
Nope, that doesn't work... Why? Think about it this way; the DesignMode mode property uses the ISite property to do its work. But at that point of your code no properties have been set so ISite is still null which is why DesignMode will always return false.
Shortly after code execution has left the constructor for your object, then ISite will be set and DesignMode will return its proper value.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Thanx James
So the only way to go is an overloaded constructor?
|
|
|
|
|
leppie wrote:
So the only way to go is an overloaded constructor?
I don't really like that tactic because it forces the user's code to be modified from what the form designer spits out.
If at all possible I would try to delay the creation/use of the stuff that can't be done in DesignMode until the Load event or some other time.
Of course this isn't always possible so you are stuck with things like creating a different constructor.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Maybe I'm missing the point here but why not do it in the Form_Load event?
Paul
|
|
|
|
|
I think thats what James is telling us. We should only attempt to get a correct value from DesignMode after the form has been Loaded.
Something like this:
bool loaded = false;
protected override void OnLoad(EventArgs e){
loaded = true;
base.OnLoad(e);
}
Then we use:
public int SomeProperty {
get {
if (loaded & DesignMode) dosomethingelse();
return someint;
}
}
Correct me if I understand this wrong...
|
|
|
|
|
leppie wrote:
I think thats what James is telling us.
Ooops! Missed the change of name part-way down this thread.
leppie wrote:
Something like this:
Why bother with all that? There shouldn't be any need for DesignMode or overloading OnLoad. Just handle the Load event.
Paul
|
|
|
|
|
Paul Riley wrote:
Why bother with all that? There shouldn't be any need for DesignMode or overloading OnLoad. Just handle the Load event.
I guess thats to do with your own programming style. To me, its easier to override the function calling the event. You mite rather want to utilize the event, but in that case u need to keep track of it.
|
|
|
|
|
I read a lot about .NET and I've worked with VS .NET for a few days but I still cannot answer for myself the following question:
How will work programs compiled with VS .NET on other platforms? It seems a platform for developing applications for Windows and not similar to Java 2 Platform.
|
|
|
|
|
Zinj wrote:
How will work programs compiled with VS .NET on other platforms?
Someone writes or uses someone elses implementation of the .NET CLI. Of course most of those applications won't run anyway because technologies such as ADO.NET, Windows Forms, and ASP.NET aren't considered a part of the CLI. The Mono Project[^] is working on porting everything, so even those technologies will work.
Microsoft has also released Rotor[^]which is their implementation of the CLI which compiles on Windows XP and FreeBSD.
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Rotor is designed for XP and FreeBSD.
Why XP? another .net framework?
and Why FreeBSD? can't port to linux(i think the the source code in FreeBSD can port to linux very quickly)?
|
|
|
|
|
elf wrote:
Why XP? another .net framework?
and Why FreeBSD? can't port to linux(i think the the source code in FreeBSD can port to linux very quickly)?
I have no idea, I was just quoting MSDN
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Rotor is a subset of the .NET Framework. You would install that if you wanted to program apps that will port to FreeBSD or other platforms in the future. It's not really another .NET Framework, it's the framework that .NET is based upon. As for porting to Linux, think about this: Why would Microsoft want to port .NET to Linux? Linux is the biggest Windows competitor right now. If they ported it, then maybe some programmers would jump ship on Windows and still use Microsoft programming tools on Linux.
Besides that, I think the move to put it on FreeBSD is just a way to convince the people at Apple( ) to let Microsoft port it to the Mac. After all, OS X is based on the FreeBSD OS.
David Stone
But Clinton wasn't a predictable, boring, aging, lying, eloquent, maintainer-of-the-status-quo. He was a predictable, boring-but-trying-to-look-hip, aging-and-fat-but-seemingly-oblivious-to-it, lying-but-in-sadly-blatant-ways, not-eloquent-but-trying-to-make-up-for-it-by-talking-even-more, bringer-in-of-scary-and-potentially-dangerous-new-policies. And there was also Al Gore. It just wasn't *right*.
Shog9
|
|
|
|
|
|
When MS is talking about platforms, MS is talking about their own platforms, ie CE is a platform, so is 2K, so is XP, and so on.
One reason why the CLR (let Window forms alone for the moment) will never be cross-platform is that the .NET framework lacks a lot of useful and mandatory features we are used to with C++/MFC/... which in turn encourages C# developers to use what is called interop, a native bypass (which breaks cross-platform abilities).
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site. Support for development will ship at the same time as the Windows XP Service Pack 1 (SP1) release.
|
|
|
|
|
i am working on a graphics editing application in c#.
but when i wanna add a text area in some part of drawing, it seems impossible to embed WORD document or EXCEL document in it.
is it true? dotnet can't play a role as OLE container?
|
|
|
|
|
BTW, is there any method to get the aim to show RichText Style area with something you draw by programming?
I think if any one can show me how to make the richtext's background transparent will also help me a lot.
Thanks for your reading
|
|
|
|
|
There is a class in the System.Windows.Forms namespace which does this; it is called AxHost and is used for embedding ActiveX based controls.
But to quote MSDN: "You typically do not use the AxHost class directly. You can use the Windows Forms ActiveX Control Importer to generate the wrappers that extend AxHost. For more information, see Windows Forms ActiveX Control Importer (Aximp.exe)."
HTH,
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Thanks.
Yes, we can use ActiveX controls in the form of c#. By select the custom toolbox, you can pickup a lot of ocx and dll.
But how about the Document like WORD and EXCEL? I don't know how to cope with them.
|
|
|
|
|
Thanks.
Yes, we can use ActiveX controls in the form of c#. By select the custom toolbox, you can pickup a lot of ocx and dll.
But how about the Document like WORD and EXCEL? I don't know how to cope with them.
|
|
|
|
|
You've got a full working Excel sample in this directory : <vc7dir>\FrameworkSDK\Samples\Technologies\Interop\Applications\Office\Excel
Behind the wheels, you have to import the Excel typelibrary, which is either ...\Microsoft Office\Office\excel9.olb or ...\Microsoft Office\Office10\excel.exe
depending on the Excel version.
Then you can use the Excel object model as follows :
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Excel;
class AutoExcel {
public static int Main() {
Console.WriteLine ("Creating new Excel.Application");
Application app = new Application();
if (app == null) {
Console.WriteLine("ERROR: EXCEL couldn't be started!");
return 0;
}
Console.WriteLine ("Making application visible");
app.Visible = true;
Console.WriteLine ("Getting the workbooks collection");
Workbooks workbooks = app.Workbooks;
Console.WriteLine ("Adding a new workbook");
_Workbook workbook = workbooks.Add(XlWBATemplate.xlWBATWorksheet);
...
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site. Support for development will ship at the same time as the Windows XP Service Pack 1 (SP1) release.
|
|
|
|
|
Hi
I want to open a tab delimited file in Excel programatically, basically similating me double clicking it. Does anyone have a snippet on how to do this?
Thanx
|
|
|
|
|
System.Diagnostics.Process.Start("filename.xls");
This of course assumes Excel is installed.
-Domenic Denicola- [CPUA 0x1337]
MadHamster Creations
"I was born human. But this was an accident of fate - a condition merely of time and place. I believe it's something we have the power to change..."
|
|
|
|