1
  Try
        Dgrd.Rows.Clear()
        ItDataset.Clear()
        Flt = "SELECT * FROM TransView WHERE TRACom =  N'" & Trim$(T10ID.Text) & "'" Order By TRAID"
        ItDataset = GeneralDataManager.InquireData(ItDataset, Flt, "TransView")
        If Me.BindingContext(ItDataset, "TransView").Count > 0 Then
            For I As Integer = 0 To ItDataset.Tables("TransView").Rows.Count - 1
                 Dim row As String() =
                       {ItDataset.Tables("TransView").Rows(I).Item("TRAID"),
                       ItDataset.Tables("TransView").Rows(I).Item("Sender"),
                       ItDataset.Tables("TransView").Rows(I).Item("Recever"),
                       ItDataset.Tables("TransView").Rows(I).Item("TRAValue"),
                       ItDataset.Tables("TransView").Rows(I).Item("CurrnceyName"),
                       ItDataset.Tables("TransView").Rows(I).Item("TRADT"),
                       ItDataset.Tables("TransView").Rows(I).Item("OFCEName")}
                    Dgrd.Rows.Add(row)
                End If
            Next
            TXTGREDTotal.Text = Dgrd.RowCount - 1
        End If
    Catch ex As Exception
       Exit Sub
    End Try

i have Boolean AS (ItDataset.Tables("TransView").Rows(I).Item("TRAYesORNo")) how i Can Convert This Boolean To String And Add it TO My Datagridview ?

Aladein
  • 184
  • 2
  • 13

2 Answers2

1

You don't have to convert it to a String. Simply bind that source column to a DataGridViewTextBoxColumn instead of the default DataGridViewCheckBoxColumn. To do that, add a text box column to the grid in the designer and set its DataPropertyName to the name of the source column. There will now be no new column created when you bind and you'll see the text "True" or "False" instead of a check box.

jmcilhinney
  • 50,448
  • 5
  • 26
  • 46
  • thank you for Your Answer .. but i want to write Text to show it in my DataGridView . – Aladein Jul 25 '17 at 10:53
  • 1
    Gee, if only I'd known that. Except I did know that and that's why I told you how to do it. Did you not see the part where I said that text would be displayed? Was the fact that I said to use a TEXT box column not a clue that text would be the result? – jmcilhinney Jul 25 '17 at 11:00
  • Are you saying, without actually saying, that you don't want to bind your `DataTable` to the grid? If so, why not? If there's no good reason not to bind then the sensible thing to do is bind. You can do what you want, of course, but why would you not do it the most sensible way? – jmcilhinney Jul 25 '17 at 11:03
  • my question is very clear .. i want to convert Boolean to String .. in my DataGridView i Added TextBoxColumn .. i wanna check if it true or false to write string and add it to Row . – Aladein Jul 25 '17 at 11:04
  • If your question is very clear then I've already answered it, because I answered the question that it was clear to me that you were asking. If I haven't answered the question you wanted answered then it's because you didn't ask it clearly. Either way, you're wasting my time so I'm done with this. – jmcilhinney Jul 25 '17 at 12:39
  • thank you @jmcilhinney .. but realy i need to convert it to show text in my DataGridView .. and i am waiting answer for my question . i will try to find the answer .. and i will sheared it with you . thank you for your time . – Aladein Jul 25 '17 at 13:02
  • This should be the correct answer. I added the column in the designer and return TEXT in my sql query (I made a CASE for my boolean), now it shows the text i'm sending. Thanks @jmcilhinney – Germán Acosta Jul 30 '22 at 21:51
0

i find the Answer :

   Dim TRAYesORNo  As String = ""
   Try
    Dgrd.Rows.Clear()
    ItDataset.Clear()
    Flt = "SELECT * FROM TransView WHERE TRACom =  N'" & Trim$(T10ID.Text) & "'" Order By TRAID"
    ItDataset = GeneralDataManager.InquireData(ItDataset, Flt, "TransView")
    If Me.BindingContext(ItDataset, "TransView").Count > 0 Then
        For I As Integer = 0 To ItDataset.Tables("TransView").Rows.Count - 1
         If ItDataset.Tables("TransView").Rows(I).Item("TRAYesORNo") = False Then
                        TRAYesORNo = "YES"
                    Else
                        TRAYesORNo = "NO"
                    End If
             Dim row As String() =
                   {ItDataset.Tables("TransView").Rows(I).Item("TRAID"),
                   ItDataset.Tables("TransView").Rows(I).Item("Sender"),
                   ItDataset.Tables("TransView").Rows(I).Item("Recever"),
                   ItDataset.Tables("TransView").Rows(I).Item("TRAValue"),
                   ItDataset.Tables("TransView").Rows(I).Item("CurrnceyName"),
                   ItDataset.Tables("TransView").Rows(I).Item("TRADT"),
                   ItDataset.Tables("TransView").Rows(I).Item("OFCEName")}
                Dgrd.Rows.Add(row)
            End If
        Next
        TXTGREDTotal.Text = Dgrd.RowCount - 1
    End If
Catch ex As Exception
   Exit Sub
End Try
Aladein
  • 184
  • 2
  • 13