?
Solved

getting text from a row in a datagrid

Posted on 2004-10-10
5
Medium Priority
?
201 Views
Last Modified: 2010-04-23
I have a datagrid that has the first column as a boolean checkbox and the other 5 columns are textbox controls. The user will click the check box for their selection and then I want to get the values of each text box in that row to display on the next form, so I want to populate some variables to pass. How do I achieve this?

0
Comment
Question by:netravel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 10

Accepted Solution

by:
123654789987 earned 2000 total points
ID: 12273876
You have to loop through each row in the datagrid,

Dim dataTable = datagrid.DataSource
Dim firstcolumn as string
Dim seconColumn as string

for i = 0 to dataTable.Rows.Count -1
if(ctype(datagrid.Item(i,0) , boolean)
firstcolumn  = ctype(datagrid.Item(i,1) , string)
secondColumn = ctype(datagrid.Item(i,2) , string)
End if
Next i


Public Property FirstColumn As string
   Get
      Return firstcolumn  
   End Get
   Set
      firstcolumn  = value
   End Set
End Property

Public Property SecondColumn As string
   Get
      Return secondColumn
   End Get
Set
      secondColumn = value
   End Set
End Property

U can access these properties from form2.

Dim frm1 as Form1
frm1 = new Form1
 Dim str as string = frm1.FirstColumn // Like this
0
 
LVL 10

Expert Comment

by:Hans Langer
ID: 12273878
Hi,
Try This,
On the event click of the colmen checkbox use this to get the other values,


Dim Field1, Field2, Field3, Field4, Field5 As String
Field1 = Convert.ToString(DataGrid1.Item(0, DataGrid1.CurrentRowIndex))
Field2 = Convert.ToString(DataGrid1.Item(1, DataGrid1.CurrentRowIndex))
Field3 = Convert.ToString(DataGrid1.Item(2, DataGrid1.CurrentRowIndex))
Field4 = Convert.ToString(DataGrid1.Item(3, DataGrid1.CurrentRowIndex))
Field5 = Convert.ToString(DataGrid1.Item(4, DataGrid1.CurrentRowIndex))

GL
0
 
LVL 10

Expert Comment

by:Hans Langer
ID: 12273885
Sorry, a little mistake :P

Try This

Dim Field1, Field2, Field3, Field4, Field5 As String
Field1 = Convert.ToString(DataGrid1.Item(DataGrid1.CurrentRowIndex,0))
Field2 = Convert.ToString(DataGrid1.Item(DataGrid1.CurrentRowIndex,1))
Field3 = Convert.ToString(DataGrid1.Item(DataGrid1.CurrentRowIndex,2))
Field4 = Convert.ToString(DataGrid1.Item(DataGrid1.CurrentRowIndex,3))
Field5 = Convert.ToString(DataGrid1.Item( DataGrid1.CurrentRowIndex,4))

GL
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

719 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