Click here to Skip to main content
15,902,032 members
Home / Discussions / Windows Forms
   

Windows Forms

 
AnswerRe: Integrate desktop application with browser??? Pin
N a v a n e e t h7-Jul-08 23:06
N a v a n e e t h7-Jul-08 23:06 
QuestionPopulating a treeview on bases of selected node Pin
sam128747-Jul-08 8:14
sam128747-Jul-08 8:14 
QuestionDatabound column doesn't see inherited interface properties Pin
Joby17-Jul-08 6:08
Joby17-Jul-08 6:08 
AnswerRe: Databound column doesn't see inherited interface properties Pin
darkelv7-Jul-08 6:18
darkelv7-Jul-08 6:18 
GeneralRe: Databound column doesn't see inherited interface properties Pin
Joby17-Jul-08 7:50
Joby17-Jul-08 7:50 
GeneralRe: Databound column doesn't see inherited interface properties Pin
Paul Fuller23-Jul-08 9:31
Paul Fuller23-Jul-08 9:31 
GeneralRe: Databound column doesn't see inherited interface properties Pin
Joby124-Jul-08 4:21
Joby124-Jul-08 4:21 
AnswerRe: Databound column doesn't see inherited interface properties Pin
Paul Fuller24-Jul-08 6:15
Paul Fuller24-Jul-08 6:15 
Joby,

I think I have a solution that is at least a little more elegant than your current...

Given your interfaces described above, I changed the TowerList to use Generics:

public class TowerList<T> : BindingList<T> where T: ITower
{
}


Then I created a Tower class which implements ITower. Because the Interface is simply a contract, the Tower class must implement each member. For the sake of testing, I just dumped in random values into the properties so something would show up on the grid:
public class Tower : ITower
    {
        #region ITower Members

        	private double _height;
        	public double Height { get { return _height; } }

        #endregion

        #region IModule Members

        	private string _partNumber;
        	private string _partDescription;
        	public string PartNumber { get { return _partNumber; } }
	        public string PartDescription { get { return this.Name + " for part #" + _partNumber; } } 
        
        #endregion

        public String Name { get; set; }

        public Tower()
        {
            Random rnd = new Random();
            _height = rnd.NextDouble() * rnd.Next(400, 500);
            _partNumber = "X" + rnd.Next().ToString() + rnd.Next().ToString();
        }


Then in a form_load event I created a TowerList object like such:

TowerList<Tower> myTowers = new TowerList<Tower> {
	new Tower { Name = "TowerX1" },
	new Tower { Name = "TowerY2" }
	};


I then set the .Datasource property of my DataGridView control and, voilà, all the inherited properties displayed correctly!

You could also define a Towers class as public class Towers : TowerList<tower></tower> if you wanted to add special behavior to Towers lists.

Unfortunately, I don't have an answer as to why the datagrid does not bind all the inherited properties when we do the code the way you described above (I was able to replicate the behavior, though...).
QuestionData-bound DataGridView adds bogus empty row Pin
JustinInGwinnett7-Jul-08 2:47
JustinInGwinnett7-Jul-08 2:47 
Questionhow to stop the UPLOADING a file, or SAVING a file in middle by clicking cancel event. Pin
balaji_vbr6-Jul-08 18:38
balaji_vbr6-Jul-08 18:38 
AnswerRe: how to stop the UPLOADING a file, or SAVING a file in middle by clicking cancel event. Pin
Christian Graus6-Jul-08 18:56
protectorChristian Graus6-Jul-08 18:56 
AnswerRe: how to stop the UPLOADING a file, or SAVING a file in middle by clicking cancel event. Pin
N a v a n e e t h6-Jul-08 19:13
N a v a n e e t h6-Jul-08 19:13 
QuestionCustom DataBinding Question [modified] Pin
David Henry6-Jul-08 10:01
David Henry6-Jul-08 10:01 
AnswerRe: Custom DataBinding Question Pin
darkelv6-Jul-08 16:10
darkelv6-Jul-08 16:10 
GeneralRe: Custom DataBinding Question Pin
David Henry6-Jul-08 22:44
David Henry6-Jul-08 22:44 
GeneralRe: Custom DataBinding Question Pin
darkelv6-Jul-08 23:24
darkelv6-Jul-08 23:24 
GeneralRe: Custom DataBinding Question Pin
David Henry6-Jul-08 23:48
David Henry6-Jul-08 23:48 
GeneralRe: Custom DataBinding Question Pin
darkelv7-Jul-08 3:22
darkelv7-Jul-08 3:22 
AnswerRe: Custom DataBinding Question Pin
David Henry9-Jul-08 22:57
David Henry9-Jul-08 22:57 
Questionhow to implement recording sound in .net Pin
Ashok Nalam5-Jul-08 0:42
Ashok Nalam5-Jul-08 0:42 
AnswerDouble Post - Please ignore Pin
Giorgi Dalakishvili5-Jul-08 0:49
mentorGiorgi Dalakishvili5-Jul-08 0:49 
QuestionHow to handle form's ControlBox's Close Button Pin
pashitech4-Jul-08 1:06
pashitech4-Jul-08 1:06 
AnswerRe: How to handle form's ControlBox's Close Button Pin
Giorgi Dalakishvili4-Jul-08 5:30
mentorGiorgi Dalakishvili4-Jul-08 5:30 
GeneralRe: How to handle form's ControlBox's Close Button Pin
pashitech5-Jul-08 2:42
pashitech5-Jul-08 2:42 
GeneralRe: How to handle form's ControlBox's Close Button Pin
Giorgi Dalakishvili5-Jul-08 3:43
mentorGiorgi Dalakishvili5-Jul-08 3:43 

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.