Hi
Ive been trying to figure out how to take a value from a cell in a datagrid that imports data from excel so that i can take the value perform a calculation and move it to another cell on another datagrid but i cant find a way to remove the value or move it can anyone help plz its urgent!
thx

Taking Values
Zwigby
GRH65
& "Data Source=" & strCon _
& ";" & "Extended Properties=Excel 8.0;"
Dim ConnProfit As OleDb.OleDbConnection = New OleDb.OleDbConnection(sConnectionString) Dim DaProfit As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter Dim DsProfit As DataSet = New DataSet Dim strselcom As New OleDbCommand("Select * from ProfitAnalysis", ConnProfit)DaProfit.SelectCommand = strselcom
TryConnProfit.Open()
DaProfit.Fill(DsProfit)
DgProfit.DataSource = DsProfit.Tables(0).DefaultView
DT = DsProfit.Tables(0)
Catch ex As ExceptionMsgBox(ex.Message)
FinallyConnProfit.Close()
End Try End Sub Private Sub DT_RowChanged(ByVal sender As Object, ByVal e As System.Data.DataRowChangeEventArgs) Handles DT.RowChanged End SubMy VB is a bit rusty so bare with me :)
You declare your datatable Friend WithEvents then an option to bind to its event handlers becomes availible in Visual Studio.
You can then do your calculations there
pathakn
larimore
Private
Sub BtnLoadProfit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLoadProfit.Click Dim strCon As String = "C:\master 6.xls" Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _& "Data Source=" & strCon _
& ";" & "Extended Properties=Excel 8.0;"
Dim ConnProfit As OleDb.OleDbConnection = New OleDb.OleDbConnection(sConnectionString) Dim DaProfit As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter Dim DsProfit As DataSet = New DataSet Dim strselcom As New OleDbCommand("Select * from ProfitAnalysis", ConnProfit)DaProfit.SelectCommand = strselcom
TryConnProfit.Open()
DaProfit.Fill(DsProfit)
DgProfit.DataSource = DsProfit.Tables(0).DefaultView
Catch ex As ExceptionMsgBox(ex.Message)
FinallyConnProfit.Close()
End Try End Sub--------------------------------------
Once the data has loaded i want to be able to have the user enter values into certain cells and when a button is pressed the new values must be taken out, used in a calculation and then inserted into corresponding cells in another spreadsheet on another grid
Brent Clements
Not quite sure what you mean could you maybe post me some sample code
thx
Amit Puri
ok now how do i go about taking the values from the cells cause the code im using isnt working :
Dim
strVal As StringstrVal = EventArgs.item.cell(3).text
-----------------------------------------------------
ZMAN!!
In this example I've hooked into the rowchanged event, wich fires after a row in the datatable is changed. I then use the e.Row to fetch a cell value
Brian Gordon
The purpose of the datagrid control is primairly for display purposes.
If you want to manipulate the data, you should manipulate its datasource.
Can you post some code, so I can see what you are trying to do
Ali D
You can hook into the rowchanged events of your dataset. Then do your calculations and copy the result into another datagrid.