parse value in datagridview and apply value to other columns

Posted on 2006-05-03
Last Modified: 2011-09-20
I am trying to parse a value in a datagridview then apply the parsed values to additional cells.
For example:
I have a DGV with column A,B,C
in column A, the user enters Big-Mo
I want to parse "Big-Mo" and apply to
column B and C. Column B would have
"Big" and column C would have "Mo"
In VB6 I could parse it and use the
TextMatrix syntax to assign the values
to the needed columns. But I am not
sure how to go about this in VS2005(VB).
I was trying this first-----

The value will be numeric and alpha numeric and seperated by a hyphen.
Dim varhyphenPosition As Integer
varhyphenPosition = InStr(1, e.FormattedValue.ToString, ",")
DataGridViewNewOrder.Columns.GetNextColumn(Me.DataGridViewNewOrder.Column, DataGridViewElementStates.Selected, DataGridViewElementStates.Displayed)datae.ColumnIndex = 4
= Microsoft.VisualBasic.Mid(e.FormattedValue.ToString, varhyphenPosition + 1)

But no dice. Any thoughts would be grreatly appreciated.
Question by:mrhedrick
    LVL 2

    Accepted Solution

    Once you get the index of the row,

    get the value of that cell, by using the selected row.

    Dim str as string
    str = value of column A

    value of column b = str.split("-")(0)
    value of column c = str.split("-")(1)

    Author Comment

    Got it....the TextMatrix in VB6 seems so much simpler though.

     Dim separated() As String
                        separated = Split(e.FormattedValue.ToString.ToString, "-")
                        With e.RowIndex = 2
                            Me.DataGridViewNewOrder(e.ColumnIndex + 1, e.RowIndex).Value = separated(0)
                            Me.DataGridViewNewOrder(e.ColumnIndex + 2, e.RowIndex).Value = separated(1)
                        End With


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now