Click here to Skip to main content
15,881,204 members
Home / Discussions / C#
   

C#

 
GeneralRe: [Message Deleted] Pin
Pete O'Hanlon3-Aug-07 2:32
mvePete O'Hanlon3-Aug-07 2:32 
QuestionHow to Programmatically Change a Property in DesignMode Pin
Cnight Stalker31-Jul-07 10:12
Cnight Stalker31-Jul-07 10:12 
AnswerRe: How to Programmatically Change a Property in DesignMode Pin
Martin#31-Jul-07 12:15
Martin#31-Jul-07 12:15 
QuestionRe: How to Programmatically Change a Property in DesignMode Pin
Cnight Stalker31-Jul-07 12:57
Cnight Stalker31-Jul-07 12:57 
AnswerRe: How to Programmatically Change a Property in DesignMode Pin
Martin#31-Jul-07 20:46
Martin#31-Jul-07 20:46 
GeneralRe: How to Programmatically Change a Property in DesignMode Pin
Cnight Stalker1-Aug-07 10:18
Cnight Stalker1-Aug-07 10:18 
GeneralRe: How to Programmatically Change a Property in DesignMode Pin
Martin#1-Aug-07 20:56
Martin#1-Aug-07 20:56 
NewsRe: How to Programmatically Change a Property in DesignMode Pin
Cnight Stalker2-Aug-07 15:08
Cnight Stalker2-Aug-07 15:08 
Yata!
I did it Big Grin | :-D .

The solution, in one word (or phrase) was DesignerTransaction.

After inspecting the Add and Remove events in my DesignerControl, I devised what you can see in the following snippets, which works perfectly:
[Designer(typeof(MyTabControlDesigner))]
public class MyTabControl : UserControl
{
	protected override void OnMouseDown(MouseEventArgs e)
	{
		if ((tabPageNext = GetHitTest(e.Location)) != null)
		{
			tabPageLast = TabPageFocused;
			if (DesignMode)
			{
				ISelectionService s = (ISelectionService)GetService(typeof(ISelectionService));
				ArrayList a = new ArrayList();

				a.Add(tabPageNext);
				s.SetSelectedComponents(a);
			}
			else
				OnSelectionChanged();
		}
		base.OnMouseDown(e);
	}

	internal void OnSelectionChanged()
	{
		// update focused page
		TabPageFocused = tabPageNext;
	}

	// return true once a selection is freshly made
	internal bool SelectionIsFresh()
	{
		if (TabPageFocused != tabPageLast)
			return false;
		tabPageLast = new TabPageEx();
		
		return true;
	}

internal class MyTabControlDesigner : ControlDesigner
{
	void OnSelectionChanged(object sender, System.EventArgs e)
	{
		IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
		IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService));
		DesignerTransaction dt;
		
		// validate selection
		if (!tabControl.SelectionIsFresh())
			return;
		// forward a selection event to the control
		dt = dh.CreateTransaction("Select MyTabPage");
		cs.OnComponentChanging(tabControl, null);
		//
		tabControl.OnSelectionChanged(); // updates to the control happens here, dt record it for IDE Undo
		//
		cs.OnComponentChanged(tabControl, null, null, null);
		dt.Commit();
	}

I hope this helps anyone else in a similar situation.

Thank you for your assistance, Martin Rose | [Rose] , the only person who cared during my plight Cool | :cool: .

Soog.
GeneralRe: How to Programmatically Change a Property in DesignMode Pin
Martin#2-Aug-07 20:43
Martin#2-Aug-07 20:43 
QuestionUpdating/changing Items in a ListBox with a TextBox Pin
stephan.smolek31-Jul-07 9:49
stephan.smolek31-Jul-07 9:49 
AnswerRe: Updating/changing Items in a ListBox with a TextBox Pin
bit_cmdr31-Jul-07 11:00
bit_cmdr31-Jul-07 11:00 
GeneralRe: Updating/changing Items in a ListBox with a TextBox Pin
stephan.smolek31-Jul-07 20:44
stephan.smolek31-Jul-07 20:44 
QuestionAverage image brightness Pin
newb2vb31-Jul-07 9:41
newb2vb31-Jul-07 9:41 
AnswerRe: Average image brightness Pin
Christian Graus31-Jul-07 11:39
protectorChristian Graus31-Jul-07 11:39 
GeneralRe: Average image brightness Pin
newb2vb31-Jul-07 12:15
newb2vb31-Jul-07 12:15 
GeneralRe: Average image brightness Pin
Christian Graus31-Jul-07 17:32
protectorChristian Graus31-Jul-07 17:32 
GeneralRe: Average image brightness Pin
newb2vb31-Jul-07 14:19
newb2vb31-Jul-07 14:19 
GeneralRe: Average image brightness Pin
Christian Graus31-Jul-07 17:33
protectorChristian Graus31-Jul-07 17:33 
AnswerRe: Average image brightness Pin
Luc Pattyn31-Jul-07 13:53
sitebuilderLuc Pattyn31-Jul-07 13:53 
QuestionC# Multithreading, GUI hangs while loading Pin
Justincc31-Jul-07 7:11
professionalJustincc31-Jul-07 7:11 
AnswerRe: C# Multithreading, GUI hangs while loading Pin
Luc Pattyn31-Jul-07 7:22
sitebuilderLuc Pattyn31-Jul-07 7:22 
GeneralRe: C# Multithreading, GUI hangs while loading Pin
Justincc31-Jul-07 7:29
professionalJustincc31-Jul-07 7:29 
GeneralRe: C# Multithreading, GUI hangs while loading Pin
PhilDanger31-Jul-07 7:38
PhilDanger31-Jul-07 7:38 
GeneralRe: C# Multithreading, GUI hangs while loading Pin
Justincc31-Jul-07 10:05
professionalJustincc31-Jul-07 10:05 
GeneralRe: C# Multithreading, GUI hangs while loading Pin
PhilDanger31-Jul-07 10:21
PhilDanger31-Jul-07 10:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.