|
Use the navigating event, check the WebBrowserNavigatingEventArgs its .TargetFrameName to see if it match the main window or a subframe within it. If there is a name mismatch then you just set .Cancel=true; and it'll stop without loading the url...
|
|
|
|
|
Hi,
What i want to be able to do is compare two images.
eg: image == Properties.Resources.backupImage
But if i do this, since image is a System.Drawing.Image object, it will always be false. Any ideas how to do this?
Regards,
Gareth.
|
|
|
|
|
What is it exactly that you're trying to achieve. Do you really want to compare the content of the picture, as in .. 'find the seven differences' or do you want to compare the filesize, filename .. that sort of things.
|
|
|
|
|
Hi Gareth,
I think you better provide more contextual info before we try and answer this one...
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
The reason it's not working, I think, is because Properties.Resources.SomeImage will always return a newly constructed image. That's why (Properties.Resources.SomeImage != Properties.Resources.SomeImage)
You'll want to try something like this:
Image backupImage = Properties.Resources.backupImage;
bool equal = image == backupImage;
|
|
|
|
|
I've googled and can't find any solutions that work.
I have a class called People that has two public properties of type string - Firstname and Surname.
I have a second class PeopleCollection : ArrayList that is an ArrayList of People objects.
Using the IComparable interface and CompareTo methods on the People class I can successfully sort by either property by specifying .Firstname or .Surname in the CompareTo method.
What I need to be able to do is sort on both fields so if the PeopleCollection instance held this data:
item[0].Firstname = "Dave" | item[0].Surname = "Smith"
item[1].Firstname = "Dave" | item[1].Surname = "Jones"
item[2].Firstname = "Andrew" | item[2].Surname = "Jones"
item[3].Firstname = "Andrew" | item[3].Surname = "Zzz"
after sorting it would be:
item[0].Firstname = "Andrew" | item[0].Surname = "Jones"
item[1].Firstname = "Andrew" | item[1].Surname = "Zzz"
item[2].Firstname = "Dave" | item[2].Surname = "Jones"
item[3].Firstname = "Dave" | item[3].Surname = "Smith"
Both columns sorted with field1 (Firstname) having priority and field2 being 'subsorted'.
I'm sure this is posible using IComparer but I just can't figure it out!
Dave
|
|
|
|
|
Hi,
you need a CompareTo method that compares the first sorting property first;
if the result is zero (which means the first property is indecisive), compare the second,
etc. until you have a decision on the relative sort order.
So it could look like this:
int diff=People1.Firstname-People2.Firstname;
if (diff==0) diff=People1.Surname-People2.Surname;
if (diff==0) diff=....;
return diff;
[CORRECTION] the - operator is not appropriate for string compare;
use diff=string.Compare(People1.SomeProperty, People2.SomeProperty); instead;
remark: Compare() has overloads to control case sensitivity [/CORRECTION]
-- modified at 14:39 Thursday 6th September, 2007
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks Luc, I can see how that may work. Getting this error message though:
Operator '-' cannot be applied to operands of type 'string' and 'string'
|
|
|
|
|
You don't want to use the '-' operator. You can compare string using String.Compare(str1, str2). This returns an integer that would give you proper sorting. You can ignore case if you want by using String.Compare(str1, str2, true).
So the code would be something like:
Int32 order = String.Compare(p1.FirstName, p2.FirstName, true);
if (0 == order)
order = String.Compare(p1.LastName, p2.LastName, true);
return order;
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
sorry, my mistake, it is OK for integer data; for strings what you can do is:
diff=String.Compare(string1, string2);
which also offers an optional "ignore-case" argument.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks I'd actually just figured it out.
int diff = string.Compare(this.Surname, tmpObj.Surname);
Works perfectly! I wish I'd asked about 8 hours ago when I started working on this :->
Dave
|
|
|
|
|
DaveyM69 wrote: I wish I'd asked about 8 hours ago
Well, it is OK to try and solve a problem yourself. Analyzing a problem,
trying different approaches, and searching effectively all are part
of the learning curve; of course if these don't bring the solution in a
reasonable amount of time, you should launch a question on a forum like this one.
And once you got a solution, reflect on why you did not find that by yourself and/or sooner.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi..
could someone plz help me out..
I want to create a number of classes. i was told to use nested classes. but im a bit unclear as to how to do this.
Looking at my tables in my database, i have the followin tables: User(list of pc users), Logon(has date,user and pc), File(the file on that PC), PC, Group(the group to which that pc belongs). With these tables i want to generate reports.
Ive started creating the class for User but now how do i go about creating the rest?
|
|
|
|
|
rcwoods wrote: I want to create a number of classes. i was told to use nested classes. but im a bit unclear as to how to do this.
public class OuterClass
{
public class NestedClass
{
}
}
rcwoods wrote: Looking at my tables in my database, i have the followin tables: User(list of pc users), Logon(has date,user and pc), File(the file on that PC), PC, Group(the group to which that pc belongs). With these tables i want to generate reports.
Ive started creating the class for User but now how do i go about creating the rest?
What has this got to do with nested classes?
How you created the other classes? In the same way as you created the User class I would guess.
|
|
|
|
|
rcwoods wrote: I want to create a number of classes
Maybe you mean linked classes? So as to follow the Relationships that exist (supposedly) between the database tables.
If so then you probably want something like:
<br />
public class User<br />
{<br />
}<br />
<br />
public class PC<br />
{<br />
}<br />
<br />
public class Logon<br />
{<br />
private User _user;<br />
public User User<br />
{<br />
get { return _user; }<br />
set { _user = value; }<br />
}<br />
<br />
private PC _pc;<br />
public PC PC<br />
{<br />
get { return _pc; }<br />
set { _pc = value; }<br />
}<br />
<br />
Kinda like that?
-- modified at 15:38 Thursday 6th September, 2007
|
|
|
|
|
Jason Hanford-Smith wrote: Colin Angus Mackay wrote:
I want to create a number of classes
I never said that - You are misquoting me. Your response should have been addressed to the OP.
|
|
|
|
|
Wow, I've never seen such a touchy bunch.
Apologies... May I never put words in your mouth again.
|
|
|
|
|
I just think the CP regulars are starting to get a bit tired of bad subjects, posts for finished code, false quotations, students trying to take the easy road through programming lessons, multi posting, cross-posting, off-topic questions/answers and so on.
We've all been growing a bit touchy I guess.
-Larantz-
|
|
|
|
|
Yep - I'm going to try some activity that doesn't require a lot of brain power. I'm going to paint my hallway.
|
|
|
|
|
And the color of the day is - black I presume?
Happy painting!
-Larantz-
|
|
|
|
|
Dulux Daffodil white in a silk finish, actually.
|
|
|
|
|
That's me finished one wall and I've cleaned up for the evening. Tomorrow I'll try and finish the rest of the hall. (Well, at least the first coat - The previous owners had a big brown rectangle painted on the wall, I think that area might require an extra coat because I can still see it, just.)
|
|
|
|
|
At the risk of hijacking the OP's question, what sort of problem maps more appopriately to a nested "composition" design?
I just read one illustration that used a car and its engine as an example. They argued that composition, and a nested engine class, made sense, because a car cannot work without an engine. But this doesn't make much sense to me, as a car could have any number of types of engine or the engine could be removed completely (as happened to my car yesterday) and replaced.
Me: Can you see the "up" arrow?
User:Errr...ummm....no.
Me: Can you see an arrow that points upwards?
User: Oh yes, I see it now!
-Excerpt from a support call taken by me, 08/31/2007
|
|
|
|
|
Hi,
you don't need nested classes: you can create all classes at the top level of some namespace.
IF a class is to be used only inside some other class, then you CAN turn it into a nested
class, and completely hide it from the outside world. That would offer a higher degree of
encapsulation, at the risk that you sooner or later want to use the inner class independent
of the containing class...
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Ah, thanks Luc.
The more I know about C# the less I know - and there's another mystery solved.
Me: Can you see the "up" arrow?
User:Errr...ummm....no.
Me: Can you see an arrow that points upwards?
User: Oh yes, I see it now!
-Excerpt from a support call taken by me, 08/31/2007
|
|
|
|
|