|
Use a .config file - the standard configuration file for .NET applications. Besides including all sorts of runtime configuration, key/value app settings, and what not - it's also an extensible system. See the IConfigurationSectionHandler interface in the System.Configuration namespace in the .NET Framework SDK for more information.
This is best, IMO, because it keeps an application's configuration in a common place and works with the .NET configuration model, which also includes general settings using the machine.config file.
While the documentation I mentioned should mention this, a .config file is either Web.config for ASP.NET or MyApplicationName.exe.config (obviously, replace "MyApplicationName" with the actual exec name) and is in the same directory as the application. This is all default, anyway.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Duh, I should have thought about that. For some reason the standard .config completely slipped my mind. Thanks very much Heath.
Brian
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." - Douglas Adams
|
|
|
|
|
I have a form, and on this form is a Panel control. When the form is inherited, I want the developer to be able to click on the form itself, or on the panel, and have a set of DesignerVerbs appear. What Designers and Base Designers should I use with the Designer attribute?
Thanks in advance for any ideas.
Kyosa Jamie Nordmeyer - Cho Dan
Portland, Oregon, USA
|
|
|
|
|
The form should use a derivative ParentControlDesigner . As far as the internal panel goes, you'll need to make it public so that the developer can actually select it, IIRC, otherwise the designer treats it as just part of the form that can't be selected individually. For that, you could either extend the Panel and attribute your derivative class with a ControlDesigner or ParentControlDesigner , or use the methods of the ParentControlDesigner attributed on the Form to add menu items to the ContextMenu .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks Heath! That did the trick. I played with all sorts of designer and root designer patterns, but never thought to change the access level of the Panel. I changed it to 'protected', actually, and that worked great.
So second question. This one's not a huge deal, just an eye sore in my opinion. Can you make the Panel control NOT show up in the property browser? I.E. Even though the Panel is there, the property browser should still show 'Form1', or whatever.
Thanks again! This has been kicking me for some time. D'oh!
Kyosa Jamie Nordmeyer - Cho Dan
Portland, Oregon, USA
|
|
|
|
|
I highly doubt it - this is a function of the designer, i.e. VS.NET.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
That's what I figured. Thanks.
Kyosa Jamie Nordmeyer - Cho Dan
Portland, Oregon, USA
|
|
|
|
|
|
You need to add the System.Drawing.dll assembly to your project. Right-click on your project, select Add Reference, then double-click the System.Drawing.dll assembly and click OK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
You don't need to draw the shadow yourself. Just add your menu item and the menu component in Office takes care of the rest.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Exactly that's my problem!
I tried to draw the image's shadow like this, but it looks not very great.
ControlPaint.DrawImageDisabled (e.Graphics,img,e.Bounds.X + 4,e.Bounds.Y + 4,Color.Transparent);
Is there any way to draw a shadow looking LIKE in Ofice XP?
|
|
|
|
|
You said you were working with Office XP components. If you only want Office XP-looking components, there are several articles here on CodeProject that show many different ways to achieve that. See the Menus and Toolbars Windows Forms Controls[^] section.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for the nice tip! 
|
|
|
|
|
anyone have a c game that uses a matrix and kills off char's
given a condition????
Help ME
|
|
|
|
|
All,
Can anyone direct me to some quality articles on how to create Web Parts for SharePoint with C#?
-Mabuti
|
|
|
|
|
Quality? No. We've been looking into SharePoint for quite some time. The best you can do is find typical "Hello, world!"-type examples. MSDN[^] has a few, and you can always google which is how we found as little as we did.
Welcome to the hell that is SharePoint documentation!
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have to agree 100%. I was put on the task of looking into coding some custom sharepoint webparts for our company and after finding virtually no documentation on it we concluded it would be cheaper just to purchase some pre-made web parts.
|
|
|
|
|
Can a column in a DataTable have ArrayList as a type?
thanks
|
|
|
|
|
DataColumn.DataType supports only the base types in .NET. See the property documentation in the .NET Framework SDK for more information.
Besides, even if it could you would have problems getting/setting that from/in a database if you use a DataAdapter or anything, as well as displaying it in data-bound controls like the DataGrid , which would force you to implement your own DataGridColumnStyle making your DataSet and your data-bound controls tightly coupled.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
how do i load .tiff images into a document and print them.
i want to build the document first with all the images and just send the document to be printed
chad
|
|
|
|
|
If you're referring to a document format like Word documents, then you need to use the Office PIAs which providing printing methods.
If you want to create a conceptual document that merely holds a list of images, then it's a different story.
You could, for example, extend PrintDocument and add an ArrayList or something that contains images. In your print event overrides you need to not only enumerate those images (not in the handler, mind you, but keeping track of the position since the PrintPage event is called once per printed page) but determine whether or not one image will fit on a page in whole or in part. There are plenty of examples of this both on MSDN[^], CodeProject (I believe), and elsewhere on the web. It's really not difficult, though, you just have to keep track of state or decide to resize your images - or allow for both and use a user preference to determine which way to go.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
would this print out more the one copy of my image . if not what would i have to change
public string[] files=new string(2)
Private Sub printButton_Click(sender As Object, e As EventArgs)
Try
files[0]= "C:\My Folder\MyFile.bmp"
files[1]= "C:\My Folder\MyFile.bmp"
' Assumes the default printer.
Dim pd As New PrintDocument()
AddHandler pd.PrintPage, AddressOf Me.pd_PrintPage
pd.Print()
Catch ex As Exception
MessageBox.Show("An error occurred while printing", _
ex.ToString())
End Try
End Sub
' Specifies what happens when the PrintPage event is raised.
Private Sub pd_PrintPage(sender As Object, ev As PrintPageEventArgs)
' Draw a picture.
ev.Graphics.DrawImage(Image.FromFile(files[0]), _
ev.Graphics.VisibleClipBounds)
ev.HasMorePages = True
ev.Graphics.DrawImage(Image.FromFile(files[1]), _
ev.Graphics.VisibleClipBounds)
' Indicate that this is the last page to print.
ev.HasMorePages = False
End Sub
chad
|
|
|
|
|
You're trying to print both images to the same page and in the same position. As I mentioned, you must keep track of state so that you print only one image per page or print them in succession. As I also mentioned, PrintPage is fired once per page.
Also, this is the C# forum, not the VB.NET forum. You even mixed C# and VB.NET, which wouldn't work in the same source file (or even the same project if you're using VS.NET as opposed to command-line compiling with two modules in the same assembly).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
sorry about the vb.net and c# code mixed i copied and modified it from msdn to past it here i don't understand what you men keep track of state can you give me a code example i can't seem to find a print that uses more than one page
chad
|
|
|
|