1
I have the following problem:
I have 2 form FrmCadastroPessoa
and FrmCadEscala
.
In FrmCadastroPessoa
have the DataGridView
shown, when I right click on a Cell, lists the scales the person is registered to.
But these scale lists are generated at runtime, at each click of mouse, i clean (.Clear()
) the ContexMenuStrip
and add the scales that came from Select
.
What can I call the FrmCadEscala
and pass the ID of the person to his builder?
The question is, how will I generate the event Click
(of ContexMenuStrip
) of something I don’t know the name or how many will have?
public frmCadEscala()
{
InitializeComponent();
Atualizar();
}
public frmCadEscala(int id)
{
InitializeComponent();
Atualizar(id);
}
Event code click on Datagridview
private void dgvPessoa_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if(e.RowIndex == -1) { return; } cmsListarEscala.Items.Clear(); if (e.Button == MouseButtons.Right)
{
// para não precisar fazer outro select, coloquei se a imagem for cancel(não tem escala) então não exibe
if (dgvPessoa.Rows[dgvPessoa.CurrentRow.Index].Cells["ESCALA"].Value == global::Row.Properties.Resources.Cancel_32x32)
{
return;
}
else
{
int n = e.RowIndex;
int m = dgvPessoa.Rows[e.RowIndex.toInt32()].Cells["ID"].Value.toInt32();
DataTable DTE = this.e.BuscarTodasEscalasPessoa(dgvPessoa.Rows[e.RowIndex.toInt32()].Cells["ID"].Value.toInt32());
if (DTE != null)
{
for (int i = 0; i < DTE.Rows.Count; i++)// coloco as escalas no CMSListarEscala
{
cmsListarEscala.Items.Add(DTE.Rows[i]["ESCALA"].ToString());
}
cmsListarEscala.Show(MousePosition); // exibo
}
}
} else
{
return;
}
Please post the code in text instead of images.
– Jéf Bueno
The idea will be to click, for example, on the option
3 VENDA
and open theFrmCadEscala
with the selected line ID?– João Martins
João Martins, Yes. But have a problem the '3 sale' is a scale of the line clicked, I add it at runtime, as I will generate the event click her, Being that it is generated according to each person?
– Gustavo Pedro
That line
int m = dgvPessoa.Rows[e.RowIndex.toInt32()].Cells["ID"].Value.toInt32();
does not put inm
theID
you want to pass to the form constructfrmCadEscala
?– Augusto Vasques
Yes, I got it, I found that I can use the CMS Click method and filter the name of the selected item, so I pass the Item Name to the constructor, search by the name id and open the Frmcadescala the way I wanted, I used it just to see if the same kkk ID was coming, where do I close the question?
– Gustavo Pedro