|
Several days ago I create a little apps, I decorate it with a nice image in background.
Suprisely , I found something weird...
button control has a backgroundImage in property grid at design time, but it doesn't exist in label control property grid.
I check in MSDN, then I found that property backgroundImage is property of Control Class. button control & label control are derived from Control Class.
So, I think property of BackgroundImage should be appear too in Label control design time.
Any one can explain to me about this "weird" thing ?
"Courage choose who will follow, Fate choose who will lead" - Lord Gunner, Septerra Core
|
|
|
|
|
Things can be overridden to not work. Practically everything in System.Windows.Forms is just a wrapper of some common control. The Statis common control (which Label wraps) does not support background images, so the label overrides that to basically do nothing. The IL (compiled form) reafirms that.
Typically, though, a label's BackColor is set to be transparent in order to show the background image.
-----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-----
|
|
|
|
|
Hi,
I would like to make an application that monitors the Internet Information Server (IIS) and pushes the web pages requested by a specific IP address to another web page on the server machine. This would then enable an administrator sitting on the server machine to see the web pages that a specific client is watching in real time.
An ugly way to do this is to continuously monitor the IIS log file and push a new page to the administrator if the relevant IP address is seen in a new log entry.
I am however thinking of some alternatives:
1) Since it is not possible to delete the current log file, this may be due to it being kept open by a file stream run by a specific logging service (not sure here!). If this is so, is it possible to attach to this file stream and monitor it for specific key words (IP addresses)?
2) There must be an event triggered before writing to the log file. In that case, is there a way to intercept the event that writes to the log file and check for the IP address before it is written to file? (It would in fact be helpful to just know which event this is, as I could then just access the log file when necessary)
Thanks for any help or input!
|
|
|
|
|
If this is ASP.NET (I'm assuming, since you're in the C# forum!), why not just write an IHttpHandler or handle the HttpApplication.BeginRequest event (usually in the Global.asax file) to do the work? The IIS logs can grow to be very huge and must be immediately accessible or IIS could bomb-out. Also, the IIS logger uses a buffer technique where large blocks of the log are pre-allocated without anything being written to them (and are allocated ahead of time). You could use the FileSystemWatcher to watch for changes, but this wouldn't be assured to work since the IIS logger doesn't automatically flush the buffer (so it seems) in order to be more responsive.
-----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-----
|
|
|
|
|
Thanks for your input Heath! Unfortunately a large part of the web pages are not ASP.NET (this is in the C# forum due to me writing in C#), othwerwise your ideas would work well.
At least I now know some more about how the log files work, and see that it is not a good idea to use them. So I guess I'm back to square one...
|
|
|
|
|
There's always the old fashion way...so get (back?) into VC++ and write an ISAPI filter!
An ISAPI filter (if you don't know, or for all the kids out there...) is mapped into IIS and handles each request. Why, ASP.NET itself is an ISAPI filter (along with file type mappings to tell IIS to let ASP.NET handle a particular extension instead of it).
They aren't hard to write, but you definitely want to make sure you write good, robust code because these handle every request and run for the lifetime of IIS.
-----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-----
|
|
|
|
|
Hi,
There is a Label control and I want to change its FontStyle (Bold, Italic, ...) at Runtime. But Font.Bold and Font.Italic are read-only properties.
How can I do it?
regards,
Mehdi.
|
|
|
|
|
label1.Font = new Font(label1.Font, FontStyle.Bold);
or
label1.Font = new Font(label1.Font, FontStyle.Italic);
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
I have class with certain properties, properties has certain attributes like DefaultValueAttribute ...now i have applied this attribute to one property...at runtime I want to change thie attribute meaning I want to change DefaultValueAttribute to some diff. value. How can I do it..?
- Atul Khalate
|
|
|
|
|
Sadly attributes can only be set at compile time
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
The attribute he's asking about in particular is only meaningful at design-time anyway, so it's unclear what he really wants.
-Blake
|
|
|
|
|
I'll ttry to clear my question here ...
I have defined one attribute,'GCDefaultValueAttribute',...which has one get/set property ,'Value',of type object.I have applied this attribute to property of class, 'Class1'.While applying attribute to this property I had passed some value (21)to the contructor of this attribute which will set the 'Value' property of GCDefaultValueAttribute. Now while loading an assembly in which this class is used,I want to change this default value from 21 to 26 for a class so that whenever new object created from this class it's property should have default value as 26 not 21 which was given at compile time.
Q1.Can I do it?
Q2.If "Yes" then How..?
Regards,
- Atul Khalate
|
|
|
|
|
I am leaving my current contract this week and I have documented my c# code to its eye teeth . But now they want a printed set of documentation so I have to print out the code comment report. Anyone know a good way of doing it ?
|
|
|
|
|
If you used the proper C# documentation syntax, you can use a popular project that I'm proud to be a part of called NDoc at http://ndoc.sourceforge.net[^]. This is widely used for C# projects by both major corporations and small projects alike. This can generate a CHM (for which the HTML Help view can print linear files) or other formats. A linear format is currently in beta stages but seems to work okay (just that the file is huge!). This won't use any internal comments, though, but I'm not sure if that's what you need.
Note: VS.NET has something similar but - as most people will agree - it's pretty basic and - to some extent - sucks.
-----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-----
|
|
|
|
|
Hi All!!
Well! I am developing a report designer like in Access but facing two problems.
1- I want to make my ToolBar Floating. So that my tools float over my designed area rather than making it fix on form.
2- on same designer I have to draw lines. when panel is repainted then all the lines disappear. SO i added them in an arraylist and repainted them all. But now whenever mouse is hovered over the panel all the lines start flickering.
Thanx in advance
sorry for my bad English.
|
|
|
|
|
Hi,
First of all, I'm new on CodeProject, so quick introducing: my names is Matthieu, I'm 26yo and live in France.
I start learning C# and I get stuck at the (easy?) following:
I have 2 string arrays, and I want to copy the first at the end of the second. I used Array.CopyTo method but it fails because the destination array is not large enough.
How can I increase the size of the dest string array ?
Thanks a lot for help,
Matthieu
|
|
|
|
|
Use Concat method of string.
s1= "Hello ";
s2 = "World"
s1 = s1.Concat(string2)
//s1 = Hello World
sorry for my bad English.
|
|
|
|
|
Thanks Itanium, but that's not what I want to do.
s1[0]="hello"
s1[1]="world"
s2[0]="good"
s2[1]="luck"
and I want to create a new string array like this:
s1[0]="hello"
s1[1]="world"
s1[2]="good"
s1[3]="luck"
Thanks a lot for help
Matthieu
|
|
|
|
|
you cannot re-dimension an array in C# like you could in VB with redim. You'll need to do something like:
string[] arrayOne = new string[]{"Hello", "World"};
string[] arrayTwo = new string[]{"Have", "a", "nice", "day"};
int newArrayLength = arrayOne.Length + arrayTwo.Length;
string[] arrayThree = arrayOne;
arrayOne = new String[newArrayLength];
int iterator = 0;
foreach(string s in arrayThree)
{
arrayOne[iterator] = s;
iterator++;
}
foreach(string s in arrayTwo)
{
arrayOne[iterator] = s;
iterator++;
}
I'm sure theres a more diginfied way, but it does work!!!
|
|
|
|
|
You've got two options here:
1. Create a new array of length= array1.length + array2.length, then use two consecutive Array.CopyTo() calls, one using zero as the index to start at, one using array1.length.
2. If you don't mind the minor performance hit from using a ICollection based object, take a look at System.Collections.ArrayList:
using System.Collections;
ArrayList array1 = new ArrayList();
array1.Add("hello");
array1.Add("world");
ArrayList array2 = new ArrayList();
array2.Add("Bonjour");
array2.Add("le monde");
array1.AddRange( array2 );
now array1 should contain (boxed as objects):
"hello",
"world",
"Bonjour",
"le monde"
Hope that helps...
Jeremy Kimball
|
|
|
|
|
I don't think that boxing takes place on strings, does it? Forgive me if I'm being dumb, as I have way more experience in Java than in .NET, but I believe that all strings are objects, aren't they? Class String extends/inherits from Object, not ValueType.
Also, the relative performance hit of using an ArrayList is not so minor in this case. I think that people should always program with performance in mind. Still, it's always nice to show people how to do things in different ways.
Regards,
Jeff Varszegi
|
|
|
|
|
Can any body guide me how to input password using VS.NET setup project, what i have seen is that there are text boxes which can take input but if i want to hide the text enterd in a password field i have no option. Presently what i am doing is that i have made a separate windows installer component which displays a modal dialog to input password, but it clearly seems something plugged into the setup and doesn't look like a part of setup when setup is run.
waiting for ur reply.
|
|
|
|
|
Can any body guide me how to input password using VS.NET setup project, what i have seen is that there are text boxes which can take input but if i want to hide the text enterd in a password field i have no option. Presently what i am doing is that i have made a separate windows installer component which displays a modal dialog to input password, but it clearly seems something plugged into the setup and doesn't look like a part of setup when setup is run.
waiting for ur reply.
|
|
|
|
|
The VS.NET setup project can't really be modified from what it supports. It's very basic. You should look into something like Wise Solutions for a real MSI development environment.
You could, however, add a new form (VS.NET has a fix number of fixed-layout forms) with a single text box then use a binary CustomAction to verify the password (almost like you are now) before proceding.
-----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 have a Form.
Within the form's class, I have a method TestConnection which tries to establish a connection to a database, and returns a bool.
I invoke this method in the Form_Load method.
With regard to what TestConnection returned, I present the user with a messagebox asking whether to try again or not.
Since TestConnection takes a long time, I want to thread it, and once it completes, i want to check the returned bool and proceed.
What is the best way of threading it?
|
|
|
|