i've got a datagrid, in it i've a column that is combobox, for binding i've binded with a list. when i run my appli, when i change the value in at combobox, it changes correctly, until here i don't have probleme, but when i select another row the value that was changed in combobox reset and it appears that it was never changed!!! what i have to do?
in xaml:
<DataGrid HorizontalAlignment="Left" CanUserAddRows="True" Height="161" Margin="162,370,0,0" VerticalAlignment="Top" Width="558" Name="da" SelectionChanged="da_SelectionChanged" IsReadOnly="False" IsHitTestVisible="True" AutoGenerateColumns="False" ItemsSource="{Binding DataCollection,Mode=TwoWay}">
<DataGrid.Columns>
<DataGridComboBoxColumn Header="Ref OSS2" MinWidth="100" x:Name="CMBXREF" IsReadOnly="False" CanUserReorder="True">
</DataGridComboBoxColumn>
<DataGridTextColumn Header="IP" IsReadOnly="False" Binding="{Binding Path=IP}" MinWidth="100"/>
<DataGridTextColumn Header="Ref OSS" IsReadOnly="True" Binding="{Binding Path=REF_OSS}" MinWidth="100"/>
<DataGridTextColumn Header="Name" IsReadOnly="False" Binding="{Binding Path=NAME}" MinWidth="100"/>
<DataGridTextColumn Header="Quntity" IsReadOnly="False" Binding="{Binding Path=QUNTITY}"/>
<DataGridTextColumn Header="Comments" IsReadOnly="False" Binding="{Binding Path=COMMENT}" MinWidth="100"/>
</DataGrid.Columns>
</DataGrid>
and i've binded like it:
List<string> AllElements = new List<string>();
List<Ordii> ordi = new List<Ordii>();
DataGridViewComboBoxColumn column = new DataGridViewComboBoxColumn();
Ordii o = new Ordii();
o.LstRef = new List<string>();
if (CngCMBX.SelectedIndex > -1)
{
string filePath0 = "ali.csv";
StreamReader monStreamReader0 = new StreamReader(filePath0);
string ligne0 = monStreamReader0.ReadLine();
while (ligne0 != null)
{
string[] temp0 = ligne0.Split(';');
if (temp0[6] != null && temp0[1] != "")
{
string[] temp = CngCMBX.SelectedItem.ToString().Split(';');
if (temp0[5] == temp[0] && temp0[6].Remove(10) == temp[1])
{
o = new Ordii("192.168.98.1", "Name: " + temp0[0], "Prepro", "1", "");
ordi.Add(o);
AllElements.Add(temp0[0]);
}
}
ligne0 = monStreamReader0.ReadLine();
}
monStreamReader0.Close();
}
else
System.Windows.MessageBox.Show("First please select your Congress");
CMBXREF.ItemsSource = AllElements;
da.ItemsSource = ordi;
...and I've this class:
public class Ordii
{
public string Ip;
public string Ref_OSS;
public string Name;
public string Quntity;
public string Comments;
public List<string> LstRef;
public string IP { get { return this.Ip; } set { Ip = value; } }
public string REF_OSS { get { return this.Ref_OSS; } set { Ref_OSS = value; } }
public string NAME { get { return this.Name; } set { Name = value; } }
public string QUNTITY { get { return this.Quntity; } set { Quntity = value; } }
public string COMMENT { get { return this.Comments; } set { Comments = value; } }
public List<string> LSTREF { get { return this.LstRef; } set { LstRef = value; } }
public Ordii(string a, string b, string c, string d, string e)
{ this.Ip = a; this.Ref_OSS = b; this.Name = c; this.Quntity = d; this.Comments = e; }
public Ordii() { this.LstRef = new List<string>(); }
}
Please help me, tnx..