473,408 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Command Pattern implementation with bound winforms controls?


We're working on implementing a Command Pattern design with our
application in order to help facilitate undo/redo. This is fine four
user actions we control which basically means menu actions.

However, it's not quite so clear for bound controls. We don't
directly interact with the change--the user makes a change in a
control, such as a grid, and the dataset stores the update. We
haven't interjected any code which we can funnel through a Command
object.

One work-around we're thinking is to react to the change events and
put a Command object in the stack wich some flag to indicate that the
action has already been accomplished (and thus the Execute method only
should be called for the Redo operation and not for the originating
operation).

How have others addressed this situation? Are there any examples
available of using Command pattern in a bound-control environment?

Thanks,

Sam

B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.
Nov 17 '05 #1
3 6106
Hi

I reviewed the thread and find that there is a similar issue in the
newsgroup below. Now I have replied to you, you may go and take a look.
Subject: Command Pattern implementation with bound winforms controls?
Newsgroups: microsoft.public.dotnet.languages.vb

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 17 '05 #2
I recently created an architecture that did this.

The undo-redo architecture was interface based with the specific
implementations for the various objects conforming to the contract of the
interface but imlementing differently depending upon object type. The
interface included a do, undo and redo method. This separated the do from
the redo and enables you to create a null do with an operative redo.

For objects such as textboxes, a change notification occurred via the
standard events which created and stacked the command object as per normal,
the system called the null do command because the assumption was that
databinding would already have effected the change and subsequent undo /
redo actions were implemented using specialised code that had knowledge of
the bound control type being undone.

I can't post code as it was for a commercial client but the process was
pretty standard Command Pattern.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Samuel R. Neff" <bl****@newsgroup.nospam> wrote in message
news:8p********************************@4ax.com...

We're working on implementing a Command Pattern design with our
application in order to help facilitate undo/redo. This is fine four
user actions we control which basically means menu actions.

However, it's not quite so clear for bound controls. We don't
directly interact with the change--the user makes a change in a
control, such as a grid, and the dataset stores the update. We
haven't interjected any code which we can funnel through a Command
object.

One work-around we're thinking is to react to the change events and
put a Command object in the stack wich some flag to indicate that the
action has already been accomplished (and thus the Execute method only
should be called for the Redo operation and not for the originating
operation).

How have others addressed this situation? Are there any examples
available of using Command pattern in a bound-control environment?

Thanks,

Sam

B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.

Nov 17 '05 #3

Thanks Bob, that looks like a good solution.

Peter's post brought up an issue I hadn't considered which is when
responding to events and putting commands with empty Do methods on the
undo stack, how do you differentiate from user initiated events and
code initiated events? Seems like that still is an issue with your
proposal.

Thanks,

Sam
On Wed, 23 Mar 2005 13:50:14 +0100, "Bob Powell [MVP]"
<bob@_spamkiller_bobpowell.net> wrote:
I recently created an architecture that did this.

The undo-redo architecture was interface based with the specific
implementations for the various objects conforming to the contract of the
interface but imlementing differently depending upon object type. The
interface included a do, undo and redo method. This separated the do from
the redo and enables you to create a null do with an operative redo.

For objects such as textboxes, a change notification occurred via the
standard events which created and stacked the command object as per normal,
the system called the null do command because the assumption was that
databinding would already have effected the change and subsequent undo /
redo actions were implemented using specialised code that had knowledge of
the bound control type being undone.

I can't post code as it was for a commercial client but the process was
pretty standard Command Pattern.


B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Aaron Ackerman | last post by:
I am using typed datasets in an N-Tier Windows app using VB.NET. I know this posting cannot be fully explained in a single post that is why I am asking for someone to point me to a real world...
1
by: TEK | last post by:
Hello I'm wondering if anyone out there might give some input/suggestions/viewpoints around the Command pattern. In my case, the number one priority for using the pattern is undo support. Some...
4
by: kaborka | last post by:
I have a WinForm with controls bound to a typed recordset that was generated by the Dataset Designer. There are several ComboBox controls with their DataSource bound to different lookup tables. ...
4
by: spamfurnace | last post by:
Hi there. Ive just been reading about the Whidbey Provider Pattern on MSDN, http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspnet/html/asp02182004.asp and i wanted to...
1
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .....
6
by: Samuel R. Neff | last post by:
We're working on implementing a Command Pattern design with our application in order to help facilitate undo/redo. This is fine four user actions we control which basically means menu actions. ...
14
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons...
6
by: Bill44077 | last post by:
Hi, I am new to the MVP pattern and one of the main reasons that we are going this route is because we are doing Scrum with 30 day sprints - so we have a continually morphing design. We are...
13
by: Dog Ears | last post by:
I've got a windows form that monitors the status of employees it polls a database every 2 seconds to fetch updates then update a underlying dataset bound to a grid using Invoke to marshal to the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.