-
April 4th, 2014, 07:24 AM
#1
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
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));
}
}
-
April 4th, 2014, 08:45 AM
#2
Re: datagridview doesn´t show the datasource
Originally Posted by tommylej
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
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
-
April 11th, 2014, 06:15 PM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|