Riaan Lehmkuhl's Blog

Subversion, Progamming, Tips & Tricks and whatever else springs to mind.
03Jan

Windows.Forms Binding errors with .Net 2.0 (Part 2)

03 January 2008 22:05 by Riaan Lehmkuhl
Hi, this is number two of my Binding error series.

I've got a BindingSource setup with the Sort property set to a valid column name and all works well, (dejavu) but the problem is when the form closes, and starts Disposing controls, I get this message:
"Sort string contains a property that is not in the IBindingList."

The solution is almost the same as in Part 1, but this time we want to clear the Sort property of all BindingSources on the form...
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) {    try {       if (disposing && (null != components)) {          foreach (System.ComponentModel.IComponent comp in components.Components) {             if (comp is System.Windows.Forms.BindingSource)                (comp as System.Windows.Forms.BindingSource).Sort = null;          }          components.Dispose();       }    } finally {       base.Dispose(disposing);    } }

Notice the bit where we loop through the components to be disposed of. Now Isn't this fun!

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Comments are closed

Riaan Lehmkuhl


Me, a disorder of the brain that results in a disruption in a person's thinking, mood, and ability to relate to others.

Recent comments

Comment RSS

Thingies

Calendar And Month List

<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

Disclaimer & Privacy

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Privacy:
We use third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.

Most comments

Cool Quote

I know that you believe that you understood what you think I said, but I am not sure you realize that what you heard is not what I meant. - Robert McCloskey