![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Hi all,
Please go through my problem and see if you can help me out.. The scenario is like this, suppose you have a text box and you registered an event Handler on TextChanged Event like this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); But if I change the Text value of this TextBox inside this TextChanged event hanlder itself, It will create a loop, because as soon as I change the text value, TextChange Event will fire, which will invoke the event Handler, So to avoide this loop, inside the event handler first i will remove the event handler on the TextChanged Event, modify the text value and again register the event handler as shown in the below code... private void textBox1_TextChanged(object sender, EventArgs e) { this.textBox1.TextChanged -= this.textBox1_TextChanged; // Remove Handler this.textBox1.Text = System.DateTime.Now.ToString(); // Update Data this.textBox1.TextChanged += this.textBox1_TextChanged; // Add Handler } this is working fine for UI objects like TextBox. But I want simulate this functionality for Outlook Tasks Items some thing like shown below.. using OL = Microsoft.office.Interopservices.Outlook; class TestOutlook { OL.Application App = null; OL.NameSpace Ns = null; OL.MAPIFolder Tasks = null; private void InitializeOutllok() { App = new OL.Application(); Ns = App.GetNamespace("MAPI"); Tasks = Ns .GetDefaultFolder(OL.OlDefaultFolders.olFolderTask s); Tasks.Items.ItemChange += Items_ItemChange; // Register Event handler } private void Items_ItemChange(Object pItem) { OL.TaskItem UpdatedTask = null; try { Tasks.Items.ItemChange -= Items_ItemChange; // Remove Handler OL.TaskItem UpdatedTask = (OL.TaskItem) pItem; // Update it UpdatedTask.DueDate = System.DateTime.Now; UpdatedTask.Save(); Tasks.Items.ItemChange += Items_ItemChange; // Add Handler } catch(Exception Ex) { } finally { System.Runtime.InteropServices.Marshal.ReleaseComO bject(pItem); System.Runtime.InteropServices.Marshal.ReleaseComO bject(UpdatedTask); } } } But I am unable to simulate this for Outlook Tasks Items(Folder) Regards Mohamed Mustafa |
Ads |
#2
|
|||
|
|||
![]()
See my reply in com.add-ins.
Please do not multipost. -- Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool - "Mustafa" wrote in message ... Hi all, Please go through my problem and see if you can help me out.. The scenario is like this, suppose you have a text box and you registered an event Handler on TextChanged Event like this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); But if I change the Text value of this TextBox inside this TextChanged event hanlder itself, It will create a loop, because as soon as I change the text value, TextChange Event will fire, which will invoke the event Handler, So to avoide this loop, inside the event handler first i will remove the event handler on the TextChanged Event, modify the text value and again register the event handler as shown in the below code... private void textBox1_TextChanged(object sender, EventArgs e) { this.textBox1.TextChanged -= this.textBox1_TextChanged; // Remove Handler this.textBox1.Text = System.DateTime.Now.ToString(); // Update Data this.textBox1.TextChanged += this.textBox1_TextChanged; // Add Handler } this is working fine for UI objects like TextBox. But I want simulate this functionality for Outlook Tasks Items some thing like shown below.. using OL = Microsoft.office.Interopservices.Outlook; class TestOutlook { OL.Application App = null; OL.NameSpace Ns = null; OL.MAPIFolder Tasks = null; private void InitializeOutllok() { App = new OL.Application(); Ns = App.GetNamespace("MAPI"); Tasks = Ns .GetDefaultFolder(OL.OlDefaultFolders.olFolderTask s); Tasks.Items.ItemChange += Items_ItemChange; // Register Event handler } private void Items_ItemChange(Object pItem) { OL.TaskItem UpdatedTask = null; try { Tasks.Items.ItemChange -= Items_ItemChange; // Remove Handler OL.TaskItem UpdatedTask = (OL.TaskItem) pItem; // Update it UpdatedTask.DueDate = System.DateTime.Now; UpdatedTask.Save(); Tasks.Items.ItemChange += Items_ItemChange; // Add Handler } catch(Exception Ex) { } finally { System.Runtime.InteropServices.Marshal.ReleaseComO bject(pItem); System.Runtime.InteropServices.Marshal.ReleaseComO bject(UpdatedTask); } } } But I am unable to simulate this for Outlook Tasks Items(Folder) Regards Mohamed Mustafa |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Before delete mail item Event Handler | RAMS | Outlook - Using Forms | 3 | March 3rd 08 01:38 PM |
AdvancedSearchComplete event handler | nana | Outlook and VBA | 3 | June 30th 07 06:10 AM |
event handler for changes to TO CC and BCC properties of mailitem | epsilon_9 | Outlook and VBA | 3 | January 15th 07 03:14 PM |
Event Handler for Folder Selected | [email protected] | Add-ins for Outlook | 6 | May 24th 06 10:44 PM |
Handling Task Item Delete Event | AtulSureka | Outlook - Using Forms | 0 | January 24th 06 10:25 AM |