|
You can either link one or more stylesheets (in the case of print preview templates, this is often a hastle), or you can use an inline <style> element (in the <head> , or in style attributes that almost all elements share:
<html>
<head>
<title>My Page</title>
<style>
body { margin: .5in; font-family: verdana,sans serif; }
p { font-size: 10pt; }
</style>
</head>
<body>
<p>Regular sentance with the 10pt font size from above.</p>
<p style="font-size: 8pt;">Smaller example sentance with inline style.</p>
</body>
<html> See Cascading Style Sheets[^] in the MSDN Library for more details.
Of course, using the inline styles with elements won't make much sense besides your header and footer, but you can use the <style> element to control the body's margins.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I already knew about how to do it that way. See - IE adds those margins relative to the page setup margins. I was wondering if you can tell it what margins to use - absolute not relative.
I'll just do the registry hack. Thanks
|
|
|
|
|
Hi,
I am new to C# and trying to create an extended Class Library that extends Hashtable.
I have created a new class like this:
'public class SerializeableHashtable: System.Collections.Hashtable'
In a method called Load i load a Hashtable object from file and try to set it to SerializeableHashtable like this:
public System.Collections.Hashtable LoadHashtableForSample()
{
System.Collections.Hashtable table = new System.Collections.Hashtable();
return table;
}
public void Load()
{
this = LoadHashtableForSample(); // fails because this is readonly
base = LoadHashtableForSample(); // fails because it is not the right context for base ?!?
}
Both of the things i try in Load fails. So the big question is: How can i assign the Hashtable object to SerializeableHashtable? (In C++ it works using the this pointer ...)
Thanks a lot in advance
Thomas
|
|
|
|
|
Thomas Gondorf wrote:
Both of the things i try in Load fails. So the big question is: How can i assign the Hashtable object to SerializeableHashtable? (In C++ it works using the this pointer ...)
You can't. SerializableHashtable is a child of Hashtable. You cannot assign a parent object to a reference pointing to the child. Also you cannot (without shooting yourself in the foot) do this in C++.
Suppose you had a method (FooBar) in SerializableHashtable which doesn't exist in Hashtable. If you were allowed to assign a Hashtable object to a SerializableHashtable reference, what would happen if you called FooBar?
It is possible for you to assign a SerializableHashtable object to a Hashtable reference.
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
But he can cast it to a SerializableHashtable .
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
|
Yeah, of course, or any other class derived from Hashtable .
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
So, i throw this idea away and store the Hashtable Object in a member of SerializeableHashtable. That will work ... Thanks a lot for your help
|
|
|
|
|
I am creating an app, that needs numerous "drivers"
the "drivers" are simple components that will accept a string, parse it and change some data in the main app.
I want to be able to load all of the drivers from a directory at run-time. So I can just place a new one in the directory and run the app without re-compiling.
Could someone please point me in the right direction. I am assuming each would go into their own DLL and be based on either an interface or a base class. But I still can't see the big picture and how they would load at run-time, or how they would fit into the main app.
Thank you very much for any help.
|
|
|
|
|
Interfaces or abstract classes are a start, but you really need a way to resolve the Type as well. This usually entails having a custom configuration section in your .config file that registers the Type associated with a particular operation, sort of how a Type to create for the <httpHandlers> section is associated with HTTP verbs and a path from which files that need to be handled are associated with the IHttpHandler or IHttpHandlerFactory .
To make it easier, you should include yourl libraries either in your application's private path (the app's directory or any directory specified in your .config file under the configuration/runtime/assemblyBinding/probing section inside the privatePath attribute. For a good example, see the ASP.NET Web Matrix (a Microsoft employee-driven, free ASP.NET designer) at http://www.asp.net/[^].
There are also several good articles available here on CP about that cover this (though many use a proprietary configuration file, while I find using the .config file that is common to all runtime applications better). You just need to do a search.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
|
I can drag & drop a image to a PictureBox(PB) by getting the filename and loading it that way, but I can't seem to be able to drag a image from IE and then drop it to my PB, it looks as though the image goes/is in my temp folder and sometimes its 0 len.
What I really want to either be able to load it as above, or have and image and send it elsewhere first.
Do I have to resort to cut/paste the image that way?
Plus I've looked at a few books and googled for hours, I'm using net 1.1 and I thought I could only have the copy cursor show when I was trying to copy an image, but the code I've seen doesn't seem to make the 'no entry' cursor show at all, anyone else experenced this?
|
|
|
|
|
This comes down to clipboard formats (clipboard formats are also used for drag-n-drop). Basically, a drag source application puts data in an IDataObject (the Shell interface, not .NET's poor wrapper) and uses one or more clipboard formats. The drop target must understand one (or more) of these formats in order to get the data out.
First, you need to determine which clipboard formats Internet Explorer is using when dragging data out of the WebBrowser control. You could use a tool like ClipSpy[^] to find out what formats it's using.
Then your app must understand one of those formats. For instance, if Internet Explorer is using the string identified by DataFormats.Bitmap (in .NET), then you can get the data and cast it to a Bitmap object, assigning that (or rather a clone (Bitmap.Clone ) to be safe) to the PictureBox.Image property.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
This comes down to clipboard formats (clipboard formats are also used for drag-n-drop). Basically, a drag source application puts data in an IDataObject (the Shell interface, not .NET's poor wrapper) and uses one or more clipboard formats. The drop target must understand one (or more) of these formats in order to get the data out.
First, you need to determine which clipboard formats Internet Explorer is using when dragging data out of the WebBrowser control.
Thanks for your reply, I think I've got the jist of it. Don't suppose you have any code or any other articles to have a look at?
|
|
|
|
|
Hi,
I've built a custom control derived from System.Windows.Forms.Label. This custom control is a part of MyControls project which is a part of a solution (this solution contains a simple windows forms application and the MyControls project).
WHat is the best way to use this custom control in the abovementioned windows forms application? THis is what I did: opened the toolbox, added the custom control into the toolbox, and then dragged it into the windows form. But this approach seems pointlessly complicated to me, and it doesn't work as I expected (my custom control disappeared from the designer after a while, but when the application is compiled it is there). Another thing is that even when the MyControls is recompiled, the changes will not show in my windows forms application
What am I doing wrong? Am I doing something stupid? Is there any other way?
Thanks for any clues/suggestions.
rado
Radoslav Bielik
http://www.neomyz.com/poll [^] - Get your own web poll
|
|
|
|
|
First, add a Project reference to your Windows Forms project by right-clicking on it, click Add Reference, then click the projects tab. Select the project containing MyControl. This makes sure that no matter which build (debug, release, or any number of custom configurations) you do, both assemblies are the right builds.
Next, forget the toolbox - type in the control into the source manually. If you use the same style/format as the other controls in the form (a field at the top, instantiated in the first secton of InitializeComponent , and the properties set under a specially formatted source comment like the others), you'll see it in the designer next time. If you use the toolbox, it might interpret the assembly location as being different from the one you added in the step above (might, might not).
The toolbox is really for third-party libraries that have one or many class libraries and want to integrated with VS.NET for developer ease and better product visibility/returns. For internal development - as you've seen - it's usually just a pain.
There's really no easier way to do it. Being able to drag a control from the solution or class views to a form would be great - like UserControls in ASP.NET - but I have seen that yet in the features list for VS.NET.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
|
I was about to ask the same question as this thread..
So are you saying that if you have access to the source and dll of a user control project, add it manually in the 'windows generated' section of code, and if you only have access to the user control as a dll (no source) add it via the toolbox?
If you add it via the toolbox it stays there for all projects, doesn't it?
Cheers,
Barry
|
|
|
|
|
Source doesn't matter. You're just adding a control reference to your source files manually to begin with, where VS.NET's designer would do it for you if you dragged it from the toolbox. Nothing more than that. Doesn't matter if the Type is defined in the current project's assembly, another project's assembly, or a third-party (or BCL) assembly. Just think of it as programming without VS.NET - frankly, I find the designers to be annoying (except, in some cases, for initial design of complex forms).
Barry Lapthorn wrote:
If you add it via the toolbox it stays there for all projects, doesn't it?
Yes, but just to be thorough, you can actually write a designer for a custom control that creates a ToolBoxItem only for the project in which the control is used. This has no relevance to this topic, but just thought I'd throw that in there.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath Stewart wrote:
You're just adding a control reference to your source files manually to begin with, where VS.NET's designer would do it for you if you dragged it from the toolbox
So once you've added it, does it render it on the control for you to then use the gui tools to size it and position it? I really should get on a c# course I'll maybe have a try later.
Cheers,
Barry
|
|
|
|
|
Yes, so long as you added it like the other controls added via the designer (instantiated in InitializeComponents and added to its parent's Controls collection). Then you're free to design it like the others. Anything done outside that method won't show in the designer.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath Stewart wrote:
Yes, so long as you added it like the other controls added via the designer (instantiated in InitializeComponents and added to its parent's Controls collection).
Ah, I see (I just knocked up a project). That means I can remove some of the controls I added to the toolbox. That's a shame, you'd hope that MS would have allowed you to add controls to the toolbox on a per project basis. Oh well. Thanks....
Cheers,
Barry
|
|
|
|
|
You can, if you want to write your own designer and get the IToolboxService service provider (or you can get it from the Control.Site property at design-time) and call IToolboxService.AddLinkedToolboxItem , which means you also have to implement IToolboxItem that instantiates your control. If you do that, the control is only added to the toolbox for the project in which its loaded.
There's also one more trick that's possible, but sometimes hard to reproduce. If you open a control in the designer (after it's compiled) it is automatically added to the toolbox for the project in which the control is located. I believe this is also supposed to work for any project in your solution - but like I said - it's hard to reproduce.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello.
I'm using the ToDouble function from the System.Convert namespace to convert from a String to Double.
I have problems using it. With a String that has the value of '56.3' I'm getting as a result a double like this 56.2999999993.
I have tried to use the ToDouble Method of the String object and I get the same result.
What I'm doing wrong ??
|
|
|
|
|
What happens when you try Double.Parse("56.3") ?
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|