i?m trying to bind a list to a datagridview. i do that:
and the datagridview has the data, but it doesn?t show anything.
could you help me?? how can i resolve the problem?? thank you
the class
i have tried to make 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
thank you
C#:
public void seedatagrid(List<myClass> liste2)
{
dgv_TraceItems.DataSource =liste2;
}
and the datagridview has the data, but it doesn?t show anything.
could you help me?? how can i resolve the problem?? thank you
the class
C#:
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 tried to make 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
thank you
C#:
public partial class MainForm : Form
{
ParserClass file= null;
UC_Configuration list_to_dgv = new UC_ChannelConfiguration();
TestInfoClass testInfo = null;
public MainForm()
{
InitializeComponent();
testInfo = new TestInfoClass();
testInfo.PropertyChanged += new PropertyChangedEventHandler(testInfo_PropertyChanged);
tbTFile.DataBindings.Add(new Binding("Text", testInfo, "FileName"));
pConfig.EnabledChanged += new EventHandler(pConfig_EnabledChanged);
}
void pConfig_EnabledChanged(object sender, EventArgs e)
{
UC_Configuration oTemp = sender as UC_ChannelConfiguration;
if (oTemp != null)
{
if (oTemp.Enabled == true)
{
file = new ParserClass(testInfo);
if (testInfo.Information != null)
{
list_to_dgv.seedatagrid(testInfo.Information);
}
}
}
return;
}
void testInfo_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (sender == testInfo)
{
if (e.PropertyName == "FileName")
{
if (testInfo.FileName != String.Empty)
{
pConfig.Enabled = true;
}
else
{
pConfig.Enabled = false;
}
}
}
return;
}
private void btlLoad_file_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog_file = new OpenFileDialog();
openFileDialog_file.RestoreDirectory = false;
openFileDialog_file.Multiselect = false;
if (openFileDialog_file.ShowDialog() == DialogResult.OK)
{
testInfo.FileName = openFileDialog_file.FileName;
}
}
}
Last edited: