Hi All
I have a WinGrid with a status column that displays an image based on the value in another column. I have used the following information for the sorting of the image column:
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=7695
My challenge now, is that I'm writing a custom function to copy the grid data to the clipboard. When I try to get the value of one of the cells in the image column, it is, of course, "System.Drawing.Image".
Is there some way I can interrogate the columns' SortComparer and find out what the value column is so I can get the value of that cell? Or some other way I can handle this?
Thanks in advance!
Hi,
I'm a little confused by your question. I assume if you are copying the grid data to the clipboard, you are looping through the grid rows. In such a case, why don't you simply ignore the image column and use the real data columns value?
Hi Mike - Thanks for the reply
The issue is that the function will be used for multiple grids, some which have image columns and some without (some with multiband, others with single band, etc), So I can't hard code what the 'real data column' is, which is why I'm trying to get the real data column through the sort comparer of the image column...
Because I always use custom sort comparers for columns containing images in these cases, I'm trying to find a way to get the values from the column i'm sorting by, rather than the image column itself...
At this point, I just make sure to use the sort comparison column's key in the .tag of the image column, so that if a image column has a .tag with a corresponding column, to take that columns value instead, but I was hoping I could find another way where I didn't need to rely on the .tag value...
Any thoughts?
Hi Mike - thanks for your help...
The function is intended to be broad enough to be used on any grid, so I don't know what the other columns key is... That's the whole point...
I'm going to just stick with my tag idea; if the column is an image column, and it has a tag value that is the key of another column, get the value from the other column. I was just hoping there was a way I could find the other column from the image columns' sort comparer.
Thanks!
If you have a cell, then getting to any other cell in the same row is easy:
cell.Row.Cells["Column B"].Value
The grid, of course, doesn't know that the image in Column A comes from the value of Column B. But you know.
Hi Mike - Okay now i'm the one who is confused...
So i'm looping through the rows and cells. (I just make a sortedlist where the key is the .header.visibleposition and the value is the column key of the visible column)On a row, I come to a cell (let's call it cell A) who's column datatype is System.Drawing.Image.Now, the image in Cell A is set based on another cell value (cell B). Other than the SortComparer, I don't think the grid has any idea that the columns are related at all.
How can I get the column key of cell B?
I'm still a little fuzzy on what the difficulty is.
So you are looping through the rows in the grid and access the visible columns. So my guess is that you are using GetFirstVisibleCol and the GetRelatedVisibleColumn method to go through the columns in the other they appear.
There are other ways to do it, of course. But at some point, you will get a column (or cell, which has a pointer back to the column) which represents your images. You can look at the Key of the column and see if it's your image column. If so, you just use the "real" column of data instead of the image column to get the value.
Are you asking how to get the other column?
If you have a column reference, then you can use column.Band.Columns[key of the real data column] to the get the column you want.