I'mdevelopingaC#applicationthatdoeslabelprintingsothatIcanuseadatagridview,whichbringsupthelinesIneedtoprint,soInowneedtoputacheckboxtoselectthelineIneedtosendtotheprinter.
Ineedtohavetheoptiontoselectallthelinesorselectonlyoneline,I'mhavingtroublecreatingthisconditioninsidemycode.
Followthecodeontheprintbutton.
privatevoidbtnImprimir_Click(objectsender,EventArgse){if(caixa_selecao.ShowDialog()==DialogResult.Cancel)return;elseEtqFraciona.PrinterSettings=caixa_selecao.PrinterSettings;etqfrac();}}
codethatloadsthedatagridview
privatevoidListGrid() { stringstrSQL=@"SELECT SC.C2_NUM AS GUIDE, SB.B1_DESC THE PRODUCT, SC.C2_XNPAIS [COUNTRY ORIGIN], CONVERT (VARCHAR (10), CAST (SC.C2_XDTFAB AS DATE), 103) AS [DT. MANUFACTURING], CONVERT (VARCHAR (10), CAST (SC.C2_XDTVALI AS DATE), 103) AS [DT. SHELF LIFE], SC.C2_XLOTEF AS [LT. MANUFACTURER], SC.C2_XLOTE AS [LT. INTERNAL], SB.B1_XDCB AS DCB, SB.B1_XCAS AS CAS, CONVERT (VARCHAR (10), CAST (SB.B1_PESO AS NUMERIC (15, 3))) + SB.B1_XSEGUM AS WEIGHT, SC.C2_XNOMFA AS MANUFACTURER, CB.CB0_CODETI AS [COD. BARS] FROM SC2020 AS SC INNER JOIN SB1020 AS SB WITH (NOLOCK) ON SB.B1_COD = SC.C2_PRODUCT INNER JOIN CB0020 AS CB WITH (NOLOCK) ON CB.CB0_LOTE = SC.C2_XLOTE WHERE C2_NUM = '"+ txtGuiaFrac.Text +"' ";
comando = new SqlCommand(strSQL, conex);
try
{
SqlDataAdapter dados = new SqlDataAdapter(comando);
DataTable dtLista = new DataTable();
dados.Fill(dtLista);
DGW_EtqFracionamento.DataSource = dtLista;
}
catch
{
MessageBox.Show("Não existem dados a serem encontrados");
}
}
Now the checkbox column in the datagridview I added by the datagridview properties in add columns.