Hello,
On my form a have two datagridview:
One datagridview is filled by DataBinding:
private void controlContractePrincipalLoad(object sender, EventArgs e)
{
string NumeClientCautat = txtCautaDupaNume.Text;
this.sClienti.DataSource = SetariAmanet.TotiClienti(NumeClientCautat);
}
A CellContentClick EVENT (its works):
private void dVizualizareClientiCellContentClick(object sender, DataGridViewCellEventArgs e)
{
DataGridView vizualizare = sender as DataGridView;
if (vizualizare != null)
{
IdClientSelectat = Convert.ToInt32(vizualizare.SelectedRows[0].Cells[0].Value.ToString());
if (IdClientSelectat != 0)
{
InformatiiDespreClientContracte();
}
}
}
AND a SelectionChanged event:
private void dVizualizareClientiSelectionChanged(object sender, EventArgs e)
{
DataGridView vizualizare = sender as DataGridView;
if (vizualizare != null)
{
IdClientSelectat = Convert.ToInt32(vizualizare.SelectedRows[0].Cells[0].Value.ToString());
if (IdClientSelectat != 0)
{
InformatiiDespreClientContracte();
}
}
}
The SelectionChanged event is not working
The error massage is: Index out of range.
The SelectionChanged event is executed two times (i think), the first time my IdClientSelectat hase a value, then he gives me an error at this line:
IdClientSelectat = Convert.ToInt32(vizualizare.SelectedRows[0].Cells[0].Value.ToString());
Where is the problem?