User (Old forums)MemberJuly 5, 2005 at 11:06 amPost count: 23064
I have a grid that is only being used to display some data. What I am trying to do is allow the user to select a row, and then click a button to load other data based off of 3 of the values in my grid. I have this:
int index = ((Xceed.Grid.DataRow)dgCompoundSummary.CurrentRow).Index;
but since my grid is a master/detail it is returning the wrong index number no matter what row i select.
Would someone send an easy example of just capturing the cell values of the currently selected row? The .net data grid uses and index and the field name such as datagrid.Columns[index][“field_name”] to capture data and the xceed grid doesn’t seem to work this way. Any help would be appreciated.
Imported from legacy forums. Posted by Nathan (had 6753 views)User (Old forums)MemberJuly 5, 2005 at 11:17 amPost count: 23064
You can get the cell value like this:<code>Xceed.Grid.DataRow row = dgCompoundSummary.CurrentRow as Xceed.Grid.DataRow;
object value = row.Cells[“field_name”].Value;</code>
Imported from legacy forums. Posted by Tommy (had 302 views)User (Old forums)MemberJuly 5, 2005 at 11:23 amPost count: 23064
Thank you for the quick post. This seems to get the value for the top level of my grid, but the data is actually in the second level, i guess the detail part of the master detail…How can i get the value of the selected row in the detail grid? I tried your code, but I get a null reference exception because the field isn’t in the top level thus it can’t find it.
Imported from legacy forums. Posted by Nathan (had 329 views)User (Old forums)MemberJuly 5, 2005 at 11:40 amPost count: 23064
Nevermind that previous post…the code is working i just had to change the case to upper on my field names and it works.
Thanks for your help…I appreciate it.
Imported from legacy forums. Posted by Nathan (had 516 views)User (Old forums)MemberAugust 2, 2005 at 9:36 amPost count: 23064
I just read your hint for getting/setting cell values in details grids. Works perfectly.
A further question: how can I sum up the numeric data of a certain column in a detail grid (if possible in the last row of this detail grid)?
Imported from legacy forums. Posted by wolfgang (had 371 views)User (Old forums)MemberAugust 3, 2005 at 12:41 pmPost count: 23064
Well, you could add a ValueRow to the FooterRows of the detail grid, and set the value of the cell of that numeric column to the sum of the DataRows. Here’s some (untested) code:<code>// create the sum-row and add it to the FooterRows of the detail grid
Xceed.Grid.ValueRow sumRow = new Xceed.Grid.ValueRow();
// calculate the sum of the column
double sum = 0.0;
foreach(DataRow row in detailGrid.DataRows)
sum += (double)row.Cells[“sumColumn”].Value;
sumRow[“sumColumn”].Value = sum;</code>
Imported from legacy forums. Posted by Tommy (had 448 views)User (Old forums)MemberAugust 4, 2005 at 3:04 amPost count: 23064
yes, but this produces a value row which reflects always the same data underneath all of my detail grids. What I need is a kind of grouping summary row under the detail grids of all the different main grid records, which updates automatically and instantly after editing one of the cell that are part of the sums.
Meanwhile I talked with the XCeed’s support team (Mathieu), and he told me that the next release 3.0 of the grid will contain such capabilites. Currently one has to resolve this problem e.g. by creating separate text boxes below the whole grid and filling it manually with programatically computed sums. A bit akward, but I already realized it, and it works.
Anyhow, thanks for your efforts!
Imported from legacy forums. Posted by wolfgang (had 501 views)User (Old forums)MemberAugust 4, 2005 at 8:59 pmPost count: 23064
I have been trying to get the value of a cell when I click on it and convert it to a string.
Unfortunately I get an exception when I try to convert
row.Cells(“celldataRowTemplate1Column1”).Value to a string in VB.
Any ideas how this can be achieved?
Imported from legacy forums. Posted by Dominic (had 906 views)User (Old forums)MemberAugust 5, 2005 at 6:27 amPost count: 23064
What kind of exception do you get?
If it’s a NullReferenceException, use this little function:<code>Public Shared Function ConvertToString(ByVal o As Object) As String
If (o Is Nothing) Then
End Function</code>Like this:<code>Dim v As String = ConvertToString(row.Cells(“celldataRowTemplate1Column1”).Value)</code>
Imported from legacy forums. Posted by Tommy (had 334 views)User (Old forums)MemberAugust 11, 2005 at 3:56 amPost count: 23064
No its not a NullReference Exception but the following:
An unhandled exception of type ‘System.Reflection.TargetInvocationException’ occurred in mscorlib.dll
Additional information: Exception has been thrown by the target of an invocation.
I tried your code snippet, but still get the same error. Any ideas what this particular exception means?
Imported from legacy forums. Posted by Dominic (had 439 views)User (Old forums)MemberAugust 11, 2005 at 5:01 amPost count: 23064
The TargetInvocationException is thrown when an error occurs in a method called via reflection (maybe even an eventhandler), and the error is not caught in the method.
Check if the TargetInvocationException has an inner exception (e.InnerException). That inner exception should be the real exception. If you can figure out what method threw the exception, you could put a try…catch construction around the code in the method, and put a breakpoint in the catch-block. That way, you can debug the code.
Imported from legacy forums. Posted by Tommy (had 7828 views)
- You must be logged in to reply to this topic.