I have a multilayered DataGrid for users to drill into some data. They see a "+" symbol, a la Excel, to expand the datarow and see the source data (see Windows Forms 2.0 Programming, Sells & Weinhardt, pg 730).
Works fine, but I would like to remove the hyperlink and present the data automagically for them (one click instead of two). Just like OK dialogs to reconfirm what you just told the dang thing to do, it will annoy people.
In other words, just open the child control and show it.
I was wondering if any one have tryed to have dynamic totals in a data grid view control, The issue I have is that the data would be constantly chaning, refiltering based on what the user selects, and if you have, could you give me some hints as to how to go about it. My other idea would be to make the totals out side of the data grid view, but I am unsure of getting summed columns, and specific cell values... any help, ideas or suggestions would be great.
You can add a calculated column to the datatable that will reflect changes when user changes some values. Here is a website explaining how to achieve it. It also provides some other useful information you might need.
This will not work definitely as value never changes and it is equal to zero all the time. Also, you are iterating over the items and calculating the same product. Instead you should sum them. You say that you need to calculate subitems * subitems but subitems of which items?
I think you are attempting to do something like...
int result = 0;
foreach (lvi item in items)
result += item.subitem * item.subitem;
is this what you are attempting to do? I am really confused by how you get 700 from that example. Just ignore in your next post the fact that the numbers are subitems, and pretend like they are already integers so your problem becomes a bit more clear to the rest of us.
That will iterate through all the ListViewItems in listview3's items collection.
With each item it will multiple the 4th subitem with the 5th subitem and add that to the result variable. Once the loop has completed, you are assigning that result variable to the Text property of the Label control.
So let's assume this ( using periods for decimal <US Standard> ):
row1: blah, blah, blah, blah, 3.5, 100
row2: blah, blah, blah, blah, 2.5, 100
result = 0
First Iteration of loop: 3.5 * 100 = 350 : result = result + 350, so result is now 350
Second Iteration of loop: 2.5 * 100 = 250 : result = result + 350, so result is now 600
result += (float)(lvi.SubItems.Text) * (float)(lvi.SubItems.Text);
And also note that result should now be a float, not an int. I didn't even consider that you were using "," as the decimal separator. I am so used to using ".", that I didn't even consider the alternative. Sorry for the confusion.
i need to get a cell value from each of the selected datagrid rows. i will then put these values in a t-sql delete from statement. i can't seem to find any clear direction on how to loop through a selected set in a datagrid and then get a particular cell value. any re-direction, or comments would be greatly appreciated.
List<int> selectedRowIndexes = new List<int>();
foreach(DataGridViewRow row in dataGrid.SelectedRows)
//To save bandwith and cputime you should make one query for deleting all the rows//instead of deleting one at a time.
... code for deleting the indexes ...
-- modified at 18:00 Friday 7th September, 2007
Fixed missing <> for the generic list.
your question is missing a lot of details. File.ReadAllLines ( from memory ) returns a string array from your file, so that's a good way to get out your username and password, is that the bit you're stuck on ? Log on to where ? What do textboxes have to do with it ? Is there a typo in your post, is the second textbox the password ? They are surely not named that ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
Last Visit: 31-Dec-99 18:00 Last Update: 21-Sep-23 2:15