Im sorry to be asking so many cast questions lately im still wraping my head around it ( the vet analogy helped)


basicly i am trying to

make a datagridview and insert information from a certian index of invoice binding sources

from that datagridview i want to select a certian row and index ( get the value of one cell basicly)

check to see if that string is empty or null
if so delete that entire line out of invoice binding source


the problem i am running into is with casting ( again) i want invoicedgv to = the value of invoicebindingsource

ive been googleing for the last 2 days and realy cant find anything to point me in the right direction

i assume its one of these possiblitys

1) the invoicedgv reqires something ilke a .value or .cell and i can add the value directly to that. ( i have yet to find anything by pokeing threw inteli sense

2) i am casting wrong ( high probablity)

3) something else




C#
Code:
DataGridView invoicedgv = (DataGridView)invoicebindingsource[index];
String invoiceCheck =invoicedgv["Name",index].ToString().Trim();
                    if (string.IsNullOrEmpty(invoiceCheck))
                    {
                        invoicebindingsource.RemoveAt(index);
                    }
vb.net = this works
VB Code:
  1. If DirectCast(Me.invoicebindingsource(index), DataRowView)("Name").ToString().Trim() = String.Empty Then
  2.                     'The Name field does not contain any non-whitespace characters.
  3.                     Me.invoicebindingsource.RemoveAt(index)
  4.                 End If