私はWindowsフォームアプリケーションで作業しています。私のデータを表示するためにdatagridviewを作成しましたが、Datagridviewから特定の列を選択し、 。DataGridViewデータを選択して1つのテキストボックスに表示するには
私は試しましたが、最後のColumnは "SEIKEN_NO"という名前のテキストボックスになっていますが、複数のカラム値を1つのTextBoxに表示します。
private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
// to set oem no, fic_no and seiken_no to textbox named particular1Txt.
dataGridView1.Refresh();
try
{
if (RB1.Checked == true)
{
int i;
i = dataGridView1.SelectedCells[0].RowIndex;
Particular1Txt.Text = dataGridView1.Rows[i].Cells["FIC_No"].Value.ToString();
Particular1Txt.Text = dataGridView1.Rows[i].Cells["OEM_No"].Value.ToString();
Particular1Txt.Text = dataGridView1.Rows[i].Cells["Seiken_NO"].Value.ToString();
}
else if (RB2.Checked == true)
{
int i;
i = dataGridView1.SelectedCells[0].RowIndex;
Particular2Txt.Text = dataGridView1.Rows[i].Cells["FIC_No"].Value.ToString();
Particular2Txt.Text = dataGridView1.Rows[i].Cells["OEM_No"].Value.ToString();
Particular2Txt.Text = dataGridView1.Rows[i].Cells["Seiken_NO"].Value.ToString();
}
通常、 'TextBox'は単一のフィールドを表示することになっています。しかし何らかの理由で複数のフィールドを表示したい場合は、 '、'のような区切り文字で文字列を結合し、その結果を 'TextBox'に表示してください。 –
数週間前に[非常によく似た質問](https://stackoverflow.com/q/46539704/472495)に尋ねられたようですが、奇妙なことに、あなたを手伝った人には返信していないようです。あなたが援助に来る人々に反応するように努力していることに気づいた場合は、ここで援助を受ける可能性が高くなります。 – halfer