Click here to Skip to main content
16,004,836 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralIntermittent: Multiple custom attributes of the same type found. Pin
cnurse20-Mar-04 23:19
cnurse20-Mar-04 23:19 
GeneralCheck if PC is Idle Pin
LC Chan20-Mar-04 20:16
LC Chan20-Mar-04 20:16 
GeneralSoftware Licensing Pin
Wayne Phipps20-Mar-04 8:17
Wayne Phipps20-Mar-04 8:17 
Generalprocess bar Pin
yousafkamal20-Mar-04 7:13
yousafkamal20-Mar-04 7:13 
GeneralRe: process bar Pin
Dave Kreskowiak22-Mar-04 8:07
mveDave Kreskowiak22-Mar-04 8:07 
GeneralUsing a column in a selected row - DataGrid Pin
ml3bf19-Mar-04 23:39
ml3bf19-Mar-04 23:39 
GeneralRe: Using a column in a selected row - DataGrid Pin
cosminadrianpopescu21-Mar-04 20:54
cosminadrianpopescu21-Mar-04 20:54 
GeneralRe: Using a column in a selected row - DataGrid Pin
Pradeep C22-Mar-04 16:50
Pradeep C22-Mar-04 16:50 
You could use this logic also to select a row, which has been clicked ( I am not sure which has better performance or whether this logic has a drawback) :


If DataGrid1.CurrentRowIndex > -1 then
DataGrid1.Select(DataGrid1.CurrentRowIndex)
End if




I think to get column value of selected row, you should get it from the underlying DataSet (or DataTable) using the CurrentRowIndex of the DataGrid

For Eg, if your DataSet ds has a table which is shown in the DataGrid, and you want to get value of column with index 3 of currently selected row,



col3Value = ds.Tables(0).Rows(DataGrid1.CurrentRowIndex).Item(3)




But this logic will fail if you have used the RowFilter to filter rows from the DataSet's default view. This is because the row index of DataGrid and that in the DataSet wont be same.

To overcome that you could use this logic to get the DataRow in the DataSet corresponding to the row selected in the DataGrid:


Private Function GetDataRow() As DataRow
Dim dr() As DataRow = ds.Tables(0).Select(ds.Tables(0).DefaultView.RowFilter)
Return dr(DataGrid1.CurrentRowIndex)
End Function




From the returned DataRow, you can take the required value :



col3Value = dr.Item(3)


Hope it helped.

----------------------------------------------------------------------------



"I think there is a world market for maybe 5 computers"
Thomas Watson, chairman of IBM, 1943

"There is no reason anyone would want a computer in their home"
Ken Olson, chairman & founder of Digital equipment, 1977

"This 'telephone' has too many shortcomings to be seriously considered as a means of communication. The device is ingerently of no value to us."
Western Union internal memo, 1876

"640 K ought to be enough for anybody."
Bill Gates, 1981

"Computers in the future may
GeneralIMAGE PROCESSING Pin
Anonymous19-Mar-04 9:51
Anonymous19-Mar-04 9:51 
GeneralRe: IMAGE PROCESSING Pin
Nadroj19-Mar-04 20:25
Nadroj19-Mar-04 20:25 
GeneralRe: IMAGE PROCESSING Pin
Dave Kreskowiak20-Mar-04 5:45
mveDave Kreskowiak20-Mar-04 5:45 
Generala database problem ! Pin
Member 52593919-Mar-04 4:50
Member 52593919-Mar-04 4:50 
Generala database problem ! Pin
Member 52593919-Mar-04 4:50
Member 52593919-Mar-04 4:50 
GeneralRe: a database problem ! Pin
BlackDice19-Mar-04 5:27
BlackDice19-Mar-04 5:27 
GeneralRe: a database problem ! Pin
Colin Angus Mackay19-Mar-04 6:25
Colin Angus Mackay19-Mar-04 6:25 
GeneralRe: a database problem ! Pin
Edbert P22-Mar-04 11:55
Edbert P22-Mar-04 11:55 
GeneralRe: a database problem ! Pin
Member 52593923-Mar-04 9:37
Member 52593923-Mar-04 9:37 
GeneralTo find a memory leak Pin
Bernhard Hofmann19-Mar-04 4:31
Bernhard Hofmann19-Mar-04 4:31 
GeneralRe: To find a memory leak Pin
Dave Kreskowiak19-Mar-04 7:50
mveDave Kreskowiak19-Mar-04 7:50 
GeneralTHANK YOU Pin
Bernhard Hofmann23-Mar-04 5:08
Bernhard Hofmann23-Mar-04 5:08 
GeneralVSS Folder browser Pin
Antony M19-Mar-04 3:14
Antony M19-Mar-04 3:14 
GeneralRe: VSS Folder browser Pin
cosminadrianpopescu21-Mar-04 21:00
cosminadrianpopescu21-Mar-04 21:00 
General.NET Framework on every machine Pin
Asad Hussain18-Mar-04 4:21
Asad Hussain18-Mar-04 4:21 
GeneralRe: .NET Framework on every machine Pin
Dave Kreskowiak18-Mar-04 5:50
mveDave Kreskowiak18-Mar-04 5:50 
GeneralRe: .NET Framework on every machine Pin
jordan200022-Mar-04 5:54
jordan200022-Mar-04 5:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.