0
내 양식에 텍스트 상자가 있고 거기에 텍스트를 DataGrid로 보내고 싶습니다.텍스트 상자에서 데이터 상자로 텍스트 보내기
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim itemName As String = txtItem.Text
Dim qty As Double = CDbl(txtQTY.Text)
Dim price As Double = CDbl(txtPrice.Text)
Dim Total As Double = price * qty
txtTotal.Text = Convert.ToString(Total)
Dim row As Integer = grdNewInvoice.Rows.Count
Dim data As TextBox() = New TextBox() {txtItem, txtQTY, txtPrice, txtTotal}
grdNewInvoice.Rows.Add()
For i As Integer = 0 To data.Length - 1
grdNewInvoice(i, row).Value = data(0)
Next
End Sub
하지만 내 데이터 그리드 행에 다음을 얻을 : 나는 다음과 같은 쓴
내가 할뿐만 아니라 다음 코드를 시도System.Windows.Forms.TextBox, Text:
[텍스트 상자 문자열] 내 설정 아무 문제가 거기에 없었다 확실히 내 데이터 그리드 : 잘 작동하고 예상대로 텍스트에 갔다하지만 난 데이터 그리드에 여러 줄에 기록되기 때문에, 내가 루프를 사용해야합니다
'grdNewInvoice.Rows(0).Cells(0).Value = itemName
'grdNewInvoice.Rows(0).Cells(1).Value = qty
'grdNewInvoice.Rows(0).Cells(2).Value = price
'grdNewInvoice.Rows(0).Cells(3).Value = Total
.
내가 뭘 잘못하고 있니?
감사합니다. 이전 삭제 된 답변도 훌륭했습니다. –
루프를 사용하여 추가를 원한다고 말했기 때문에 삭제했습니다. – Arman