datagridview doesn´t show the datasource
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: datagridview doesn´t show the datasource

  1. #1
    Join Date
    Sep 2013
    Posts
    10

    datagridview doesn´t show the datasource

    i´m trying to bind a list to a datagridview. i do that:

    Code:
    public void seedatagrid(List<myClass> liste2)
    {
        dgv_TraceItems.DataSource = new BindingList<myClass>(liste2.ToList());
    }
    and the datagridview has the data, how is in the picture, but it doesn´t show anything.

    could you help me?? how can i resolve the problem?? thank you
    Name:  data.jpg
Views: 311
Size:  65.3 KB

    the class

    Code:
    public enum TYPE
    {
        normal= 1,
        especial= 3, 
        low= 6, 
        high= 7,          
    }
    
    
    public class myClass : INotifyPropertyChanged
    {
    
        private byte number;
        private TYPE type;
        private string file;
        private bool isselected;
    
        public event PropertyChangedEventHandler PropertyChanged;
    
        public byte Number
        {
            get
            {
                return this.number;
            }
            set
            {
                this.number= value;
                this.OnPropertyChanged("Number");
            }
        }
    
        public TYPE Type
        {
            get
            {
                return this.type;
            }
            set
            {
                this.type = value;
                this.OnPropertyChanged("Type");
            }
        }
    
        public string File
        {
            get
            {
                return this.file;
            }
            set
            {
                this.file = value;
                this.OnPropertyChanged("File");
            }
        }
    
        public bool IsSelected
        {
            get
            {
                return this.isselected;
            }
            set
            {
                this.isselected = value;
                this.OnPropertyChanged("IsSelected");
            }
        }
    
        public myClass(UInt32 Data, string Text)
        {            
            this.number = (byte)((Data & 0x0000FF00) >> 8);
            this.type = (TYPE)((Data & 0x00FF0000) >> 16);
            this.file = Text;
    
        }
    
        private void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

  2. #2
    Join Date
    Sep 2013
    Posts
    10

    Re: datagridview doesn´t show the datasource

    Quote Originally Posted by tommylej View Post
    i´m trying to bind a list to a datagridview. i do that:

    Code:
    public void seedatagrid(List<myClass> liste2)
    {
        dgv_TraceItems.DataSource = new BindingList<myClass>(liste2.ToList());
    }
    and the datagridview has the data, how is in the picture, but it doesn´t show anything.

    could you help me?? how can i resolve the problem?? thank you
    Name:  data.jpg
Views: 311
Size:  65.3 KB

    the class

    Code:
    public enum TYPE
    {
        normal= 1,
        especial= 3, 
        low= 6, 
        high= 7,          
    }
    
    
    public class myClass : INotifyPropertyChanged
    {
    
        private byte number;
        private TYPE type;
        private string file;
        private bool isselected;
    
        public event PropertyChangedEventHandler PropertyChanged;
    
        public byte Number
        {
            get
            {
                return this.number;
            }
            set
            {
                this.number= value;
                this.OnPropertyChanged("Number");
            }
        }
    
        public TYPE Type
        {
            get
            {
                return this.type;
            }
            set
            {
                this.type = value;
                this.OnPropertyChanged("Type");
            }
        }
    
        public string File
        {
            get
            {
                return this.file;
            }
            set
            {
                this.file = value;
                this.OnPropertyChanged("File");
            }
        }
    
        public bool IsSelected
        {
            get
            {
                return this.isselected;
            }
            set
            {
                this.isselected = value;
                this.OnPropertyChanged("IsSelected");
            }
        }
    
        public myClass(UInt32 Data, string Text)
        {            
            this.number = (byte)((Data & 0x0000FF00) >> 8);
            this.type = (TYPE)((Data & 0x00FF0000) >> 16);
            this.file = Text;
    
        }
    
        private void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    i have made a datatable with the list and the datagridview doesn´t show anything. i donßt know what happends , but i have a problem with the datagridview

  3. #3
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,537

    Re: datagridview doesn´t show the datasource

    Hi !
    Sory I cannot see any code where you are really binding the grid to your list, When do you call the method 'seedatagrid' and where the list is filled.
    So basially the code you are showig is too less to see what you are doing
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center