Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
S

Simon Bridge

@Simon Bridge
About
Posts
10
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Data Binding to an Object that may be Read Only
    S Simon Bridge

    BindingSource is an IComponent, the main definition of a component being that it implements IDisposable, - so yes it does have a Dispose method, and this is being correctly invoked by the 'Container' on the form when it gets disposed. However, I think I have discovered the problem. The issue is the record that is currently on-screen (so it's a data-input form with text-boxes, combo's etc. - not a data-grid) When you close the form, the record currently on screen, (which was put into edit mode as soon as the record became current) is not removed from edit-mode. Turns out, there are CancelEdit() and EndEdit() methods on the BindingSource object itself. I trapped the Form.Closing event, and invoked CancelEdit() on the primary binding source for the form, and it now releases all the locks. I put in some logic to determine if the current record has pending changes, and call EndEdit() instead to keep the changes. This even works when the binding source has other data sources hanging off it (i.e. when a property of the current object/record is itself a data-source ('cos its a list), - on some forms in my system this can cause upward of 50 records being locked at one time, which was causing lots of headaches when they weren't unlocking) I am still a little unsure why you have to explicitly call either EndEdit() or CancelEdit() from the binding source - I would have put clean-up code in the Dispose method if I were writing the class. My best guess is that the Begin-End/Cancel edit semantics are more closely coupled with the DataRow and DataGridView components.

    Windows Forms wpf wcf question

  • Data Binding to an Object that may be Read Only
    S Simon Bridge

    It seems to be a big gap in the visual studio data-binding extensions - there is no support for read only entities or even read only properties. Properties that are compiled as read-only do not get treated any differently. I even implemented the ICustomTypeDescriptor interface, but the binding source, while it reads off a set of properties for each object, it only checks the "IsReadOnly" property from the first record, and it doesn't even appear to affect how it binds the data source to the controls. I am coping with the issue by: 1) each entity implements IEditableObject. 2) in the IEditableObject.BeginEdit() method, the entity attempts to acquire a lock. If it cannot acquire the lock, the entity is ReadOnly. I removed any exceptions thrown at this point: the lock fails silently. 3) I have handled the CurrentItemChanged event from the BindingSource. In this handler, I check if the entity is read-only, and update the enabled state of the associated controls. This seems to be working for now, but I am faced with another issue: the BindingSource component, doesn't always call IEditableObject.EndEdit() or IEditableObject.CancelEdit() for every item it has called IEditableObject.BeginEdit() on.... this seems like a fairly dramatic design flaw in this component. Am I not disposing of it correctly?

    Windows Forms wpf wcf question

  • Detect if ANY control is clicked inside a form, regardless of the container
    S Simon Bridge

    Hi, One other (slightly heavy handed) possibility is to override the Windows Procedure in your form. You can then intercept all the windows messages it receives, and filter down to the mouse events. eg:

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
        }
    }
    

    You can get an enum containing all the windows message constants here: [^]

    Windows Forms docker question

  • Data Binding to an Object that may be Read Only
    S Simon Bridge

    If implementing INotifyPropertyChanged allows you to tell BindingSource when an object's properties have changed (and therefore the form needs to be updated) - how would you inform the BindingSource that a particular record/object is currently read-only (or not)? I was hoping for another interface to implement, but at this point I'm open to any ideas. The read-only state comes from another user write-locking the record.

    Windows Forms wpf wcf question

  • Oracle Will Stop Providing Security Updates for Java 6 Next Month
    S Simon Bridge

    (Crippled with Laughter) :-D :rolleyes:

    The Insider News java oracle com security question

  • Changing the terms of the violent video game debate
    S Simon Bridge

    Actual, real psychology says that violent Video games actually reduce our violent tendencies through the vicarious experience. Civilised humans are now less violent than we have ever been. Most of us would go into shock simply witnessing real violence happening in front of us. But we are still living in the same bodies our caveman barbarian ancestors occupied, our bodies and brains are programmed to relieve anger and solve immediate dangers by hitting things. However this is not the way we do things any more in the civilised world - besides which most of the sources of stress we live with don't have any physical part we can hit. Thus we release this built up aggression by playing sports, and watching TV, and playing video games. Take away violent video games and violence in our society will increase.

    The Insider News php com game-dev announcement

  • Core Rot at Apple
    S Simon Bridge

    Apple has always touted it's OS lines as faster, more reliable, and mostly: more secure than an equivalent windows PC (remember the Mac and PC adds with the 'cool' mac and 'Nerdy' PC) In most cases, they were right. The problem I see is that they believe that they had these advantages because they were better, quicker, smarter and more good looking than Windows and Microsoft. My theory is that the Apple OS line had advantages due to: A far smaller and more industry focused user-base (meaning less targets for viruses, less reason to develop a virus for a Mac) a Much higher price point for Hardware and Software (when I last looked at buying a mid-range Mac, the same money would buy a bleeding-edge ultra high spec PC bundled with any software you could think of) Finally they have only a limited range of hardware to support (Apple Macs aren't built out of components by their owner, nor can almost every part of the hardware be changed at any point - Apple didn't need to develop Plug-N-Play, there wasn't anything to plug in and play with) However, now that Apple is producing Windows 7/8 compatible machines, they are going to inherit all the problems that the rest of the PC industry has been dealing with for years. They might just find out that PCs aren't better just for looking pretty and being incompatible with most malicious software. :-)

    The Insider News html asp-net com announcement

  • TED:Defend our freedom to share (or why SOPA is a bad idea)
    S Simon Bridge

    Excellent, Yes, the Outernet? Othernet? Oh, hangon. This already exists, I believe it's called AOL....

    The Lounge html com question

  • TED:Defend our freedom to share (or why SOPA is a bad idea)
    S Simon Bridge

    SOPA proposes to 'block' any site "taking, or has taken deliberate actions to avoid confirming a high probability of the use of the U.S.-directed site to carry out acts that constitute a violation." It may as well be Swahili to me, but experts in law read this to mean "that a site must actively monitor its content and identify violations to avoid blocking, rather than relying on others to notify it of such violations". How the U.S. congress proposes to create and enforce these 'blocks' I do not know. Well, we here are a community of programmers. The Internet is our domain, - who understands it better than those that helped create it? I don't necessarily agree with various plans to shut down government sites with massive, global D-DOS attacks, like those levelled at Master-card and some other corporations last year as a political protest. Instead, I think we should start working on methods to bypass these 'blocks', should they ever be put in place. Assuming a website is off-shore to the US, they have no authority to actually shut down a site, but they plan to prevent it being accessed. I think they forgot the basic reason the Internet was created: To survive a nuclear holocaust. There are so many possible paths from one point to another, that even global nuclear destruction cannot shut it down.

    The Lounge html com question

  • TED:Defend our freedom to share (or why SOPA is a bad idea)
    S Simon Bridge

    Espen Harlinn wrote:

    Remember this one too?[^]

    If SOPA gets through, code-project could end up being shut down because a link such as this was posted on a forum. If a home video taken in someone's lounge room happened to catch the TV on in the corner, that is copyright violation according to this new bill, and a first time offender could end up in jail, and any website even linking to the content would be culpable. If SOPA gets through, code-project would be deemed responsible for ensuring that any user-posted content did not violate any form of copyright. It would cost a fortune to police, so they would have to shut down, or start charging us, - per post. I wouldn't have posted this message if I had to pay to do it. But of course, the US congress isn't trying to police the world, or censor the Internet with SOPA, nooooo, It's all about Pirates. Evil, murdering , swashbuckling, patch-over-one eye, peg-legged Internet pirates, threatening us all with their lethal you-tube videos. (Is the sarcasm coming through there?, hard to be sarcastic in print, and I don't see a sarcasm emoticon on the right)

    The Lounge html com question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups