[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

parse value in datagridview and apply value to other columns

Posted on 2006-05-03
2
Medium Priority
?
408 Views
Last Modified: 2011-09-20
Hello,
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.
0
Comment
Question by:mrhedrick
2 Comments
 
LVL 2

Accepted Solution

by:
af4643 earned 800 total points
ID: 16599128
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)
0
 

Author Comment

by:mrhedrick
ID: 16599905
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

Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

834 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