Question

Locked

VB.NET Datagridview Selected Cell / Row

By martinbullock15 ·
Hi

I have a DataGridView which is populated from a query. It only has two columns, I want to be able to select a cell, then when a button is click it gets the value in Column 1 assigns it to one textbox and then gets the value of Column 2 and assigns that a different textbox of the Row where the Cell is Selected.


------Col1--|--Col2--
Row1---A----|---1----
Row2---B----|---2----
Row3---C----|---3----


So if Col1/Row2 was selected it highlights the whole row but returns textbox1 "B" textbox2 "2"

I have set the DataGrid Property to "FullRowSelect" and MultiSelect "False" so whereever the user clicks it selects the row and therefore all the relevant data is highlighted and also avoids the problem of multi selections.

Any suggestions would be very grateful

Kind Regards

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

split...remove

by brian In reply to VB.NET Datagridview Selec ...

thought, add a button as col3...on button click, tell it to read information from sql statement on row one, combine with row two (assuming that you are splitting the pull on a comma or semicolon or something. tell it to split again on that information and set the textbox.text to what ever the first part is before the semicolon or split and then drop the rest...i know there is a better way to explain this, but this is the best i can come up with this early in the morning.....example code as follows (VB side):

Dim chargeto As String = poStuff.getcodeLocations()
chargeto = Mid(chargeto, 1, (Len(chargeto) - 1))
Dim chglist = Split(chargeto, ";")
Me.chargeto_Box.Items.AddRange(chglist)

that code popluates the information in a drop down box for me in a purchase order program i am writing....there is a location as to where the PO is being charged and a corrosponding number for accounting for that location....it looks like this in the display.... "location-number" or "office-1"

Back to Web Development Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums