DataGridView / sorting data

Hi guys,

I have a dataGridView with a few columns and a large number of rows. Each row corresponds to a file. Specific data from each file is place in particular cells (i.e. columns).

There are two columns of interest to me at the moment. One of these columns displays text, the other displays a numerical value.

I would like to be able to rank the numerical values in ascending order programmatically and have the order linked to the corresponding cell with text. I can do this (numerical values only) easily by placing them values into an array and using:

Array::Sort()


And then transferring the ordered data back to the DataGridView's column.

As far as I am aware, you can't have a multidimensional array with different types...Or can you? And Array::Sort() is only for single dimension arrays.

Does anyone have any suggestions?


Thanks.
Last edited on
std::map<std::string,int>Map I think this could work?
I admire the excel "insert comments" cell option. I would like to reproduce this in my datagridview in .net 2.0 using c#. Could somebody give me an idea as to the approch I should take on creating the edit box.

http://www.trainingintambaram.in/cloud-computing-training-in-chennai.html
Thanks Cody0023,

With your help, I managed to solve my problem. However, I did use a vector to help sort the data; I read somewhere that map sorting isn't as efficient as sorting a vector. Anyway, data has been placed in a map. This has then been copied into a vector which was then sorted and used in a dataGridView as desired.


Thanks.

leenadeep,

I haven't used C# yet. Only C++ and windows forms stuff. If I have understood your post correctly, are you trying to mimic the 'comments' feature on excel? I.e. if a comment if present for a cell, a mouse hovering over it displays the hidden comment...

I'm sure you could do that using a dataGridView. There is a mouse hover event you could use which could trigger a message box which would display your comment... I'm not sure if the speech bubble like feature in excel is available. Alternatively, you could have a textbox somewhere that displays the comments for the cells that require it. The message box thing might get a bit annoying given that you have to click OK for it to be removed once triggered.

Not sure if this helps...Or is accurate (I'm only a beginner but learning lots daily :) ).
Last edited on
Topic archived. No new replies allowed.