1 Attachment(s)
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
Attachment 32511
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));
}
}
Re: datagridview doesn´t show the datasource
Quote:
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
Attachment 32511
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
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