|
Hi everybody.
There is a property, it's named ImageFullPath1
public string ImageFullPath1 {get; set; }
I'm gonna fire an event whenever its value changed. I know I can beware of changing with INotifyPropertyChanged , but I wanna do it with events.
I don't know how I should do it.
Could you please guide me?
Thanks.
|
|
|
|
|
INotifyPropertyChanged uses events and is there just for what you are asking. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I just hate the fact that it uses a string, however.
|
|
|
|
|
Use the alternative approach with the same result. You need a specifically named event with the default eventArgs the name must be YOURPROPERTYChanged . For best practice also supply and OnYOURPROPERTYChanged method as well. e.g.
private string _MyProperty;
public string MyProperty {
Get { return this._MyProperty; }
Set {
If (this._MyProperty != value){
this._MyProperty = value;
this.OnMyPropertyChanged(EventArgs.Empty);
}
}
}
public virtual void OnMyPropertyChanged(EventArgs e){
if (this.MyPropertyChanged != null){
this.MyPropertyChanged(this, e);
}
}
public EventHandler MyPropertyChanged;
|
|
|
|
|
I don't recall asking a question to which this was the answer.
|
|
|
|
|
Sorry, replied at the wrong level in the thread.
My appologies
|
|
|
|
|
Posted in reply to the wrong message earlier. Apologies.
Use the alternative approach with the same result. You need a specifically named event with the default eventArgs the name must be YOURPROPERTYChanged . For best practice also supply and OnYOURPROPERTYChanged method as well. e.g.
private string _MyProperty;
public string MyProperty {
Get { return this._MyProperty; }
Set {
If (this._MyProperty != value){
this._MyProperty = value;
this.OnMyPropertyChanged(EventArgs.Empty);
}
}
}
public virtual void OnMyPropertyChanged(EventArgs e){
if (this.MyPropertyChanged != null){
this.MyPropertyChanged(this, e);
}
}
public EventHandler MyPropertyChanged;
|
|
|
|
|
|
hi,
in my case, i have a lan using sql server as data server, now one client insert or update some important data that it's highly recommended to another clients understand this operation, is there any way to make a remote delegate on all clients or something like this
ty
|
|
|
|
|
My first thought is that you'd probably have to setup a communications system with a central server that performed the database operations, and then notified all of the clients of the change..45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
thanks for ur answer,
u right, look im going to do this as easy as possible, bcoz fee for this work is only 50$.
|
|
|
|
|
|
thanx for ur answer, in my case I have 1milion record in my cached table in my form, so if 1 record has changed,then by using sqldependency 1milion record must be retrived again! is it possible to understand which record has been changed?
|
|
|
|
|
1 million? I doubt that.
Have you read the documentation? Have you actually tried it? I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi im building a program to scrape links from a webpage, To prevent the document complete even tfiring multiple times ive set it to the function below.
public void BrowserCallback(object sender, EventArgs e)
{
WebBrowser Thread = (WebBrowser)ThreadViewer.Controls["Thread"];
while (Thread.ReadyState.ToString() != "Complete")
{
Application.DoEvents();
}
LinkScraper CurrentForm = new LinkScraper();
MethodInfo methodInfo = typeof(LinkScraper).GetMethod(NextFunction);
methodInfo.Invoke(CurrentForm, null);
}
My problem is that referencing the current form with
LinkScraper CurrentForm = new LinkScraper();
wipes out all the created controls from the previous method, Is there any way to use methodInfo.Invoke without having the same issue ?
|
|
|
|
|
First, you should be posting this in the asp.net forum.
Second, you could store the data in server variables (there's a word for these, but I can't for the life of me remember it) and retrieve them in the new instance of the form..45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
If this is a WinForms app (I can't tell from your post), then:
1. you are in the right forum;
2. if using WebBrowser, you should rely on the WebBrowser.DocumentCompleted event (and watch the URL that goes with it to decide whether it is the last one)
3. if you don't need to see the web page, you would be better of using HttpRequest and HttpResponse, which don't use any Control, and can work synchronously. This is how I do most web scraping.
Some coding comments:
1. a WebBrowser and a Thread are two different things, so calling a WebBrowser Thread is confusing everyone, you in the first place.
2. having a loop of DoEvents() is a horrible hack.
3. you should not use strings for something that is not inherently a string, so please replace Thread.ReadyState.ToString() != "Complete" by Thread.ReadyState!=WebBrowserReadyState.Complete
tyjnfghnfgsdf wrote: To prevent the document complete even tfiring multiple times ive set it to the function below.
I don't understand you here. Is this the method that will handle the DocumentCompleted event? having it wait for completion doesn't achieve much; the multiple events will fire anyway, so they will get queued in the message queue and confuse you with some delay.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
hi,
i have a main form. it has list view of items that when clicked will open up another form without closing the main form.
i did a inactivity timeout where user will be require to login again. if that happen, how do i close all current open form??
|
|
|
|
|
You need to keep form objects that are open in a collection. When relogin requires, loop through this list and dispose everything. Best wishes,
Navaneeth
|
|
|
|
|
N a v a n e e t h wrote: loop through this list and dispose closeeverything.
Don't use dispose on a form that is currently displayed - unpredictable things may occur!If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
When I say dispose everything, I didn't meant to call Dispose() method. BTW, how it can cause unpredictable things? Best wishes,
Navaneeth
|
|
|
|
|
If the form has a background thread working, it could be using resources that you have disposed. If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
Application.OpenForms will return a Forms[] for all open forms. You can for loop through it closing the ones you no longer need (with Form.Close(), obviously). Do not try to foreach loop through, as the Close() may remove it from the array. If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
im implementing windows mobile using compact framework so there isn't application.openforms.
is there something else similar?
|
|
|
|
|
Not unless you create it yourself - keep a copy of the form object when you do the create, chain into the FormClosing event and remove it when it closes. You can then manually Close() each open instance. If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|