I have a listview (details view) and I display a column of images and a column of text,
It's possible to display the image in the second column (without OwnerDraw)? I want to put the text in the first because only the first column can be edited by the user (LabelEdit property)
ListViewItem lvi = new ListViewItem("");
lvi.ImageKey = "image"; // column 1
lvi.SubItems.Add("subitem 2"); // column 2
Thank You
UPDATE
Native listview supports images in subitems (LVS_EX_SUBITEMIMAGES) since before win 98 but they didn't include it in .NET.
http://msdn.microsoft.com/en-us/library/windows/desktop/bb774732(v=vs.85).aspx
A codeproject example
http://www.codeproject.com/Articles/7630/ListView-with-Image-on-SubItems
No, without OwnerDraw it is not possible.
In your case the simplest thing is to manage the editing of other columns instead of manage the OwnerDraw. There are some example of how to do it:
example 1
example 2
example 3
ecc...
Related
I have a bar chart with different bar colors. Below in a table I just want to indicate what each color means.
Can I do something like that in SSRS?
Im sure I can create another column on a left and assign each color to a cell. But is any way I can display it the way its on a picture above?
I tried to use indicators for that but I guess it needs conditions.
You can do this with custom code.
Loose steps to follow are:
Create a list to hold the graph
Add the graph
Inside the list and below the graph, add a tablix
The tablix will row group on the same thing as the graph (so you can get a row per coloured item in the graph)
Add a column to the start of the tablix for the colour
Add the following custom code:
Private colourPalette As String() = {"#418CF0", "#FCB441", "#DF3A02", "#056492", "#BFBFBF", "#1A3B69", "#FFE382", "#129CDD", "#CA6B4B", "#005CDB", "#F3D288", "#506381", "#F1B9A8", "#E0830A", "#7893BE"}
Private count As Integer = 0
Private mapping As New System.Collections.Hashtable()
Public Function GetColour(ByVal groupingValue As String) As String
If mapping.ContainsKey(groupingValue) Then
Return mapping(groupingValue)
End If
Dim c As String = colourPalette(count Mod colourPalette.Length)
count = count + 1
mapping.Add(groupingValue, c)
Return c
End Function
For the series fill on the graph, use the follow expression:
Use the same expression for the fill on the initial column in the tablix
You can use any list of codes for colour - this is the list for the default palette in SSRS.
This code ensures the same colour is picked each time the same item is used - so in the image the same colour is returned each time the same Category is returned.
The solution I use is pretty simple.
I use Windows Character Map to find a character I like. For example: ■
Copy that character and add an expression where you want to show the color icon. Your expression text will be
="■"
Then go to the Font tab and Color. Select the color you want from the menu. You can use expression logic in here to change the color dynamically. (You can refer to other answer for details there)
I'd like to highlight a single column in a WinForm StackedColumn Chart. As examples, I'm seeing how to put borders around the individual DataPoints in each Series displayed in the column and put an ArrowAnnotation pointing at one of the DataPoints, but I don’t see a way to highlight the column as a whole. For example, it would be great to have the column expand to say twice the width of the other columns and/or have a different backcolor (including the empty areas above and below the DataPoints). Is it possible to do what I want and, if so, how? C# examples are preferable but not necessary.
Thanks. Steve
You could dim every other column, using BackHatchStyle = ChartHatchStyle.Percent50 and BackSecondaryColor = Color.Black. This will make your chosen column appear brighter/highlighted.
Here's an example:
int highlightColumnIndex = 0; // Set the highlighted column here!
foreach (Series cs in chart1.Series) {
foreach (DataPoint dp in cs.Points) {
dp.BackSecondaryColor = Color.Black;
dp.BackHatchStyle = ChartHatchStyle.Percent50;
}
cs.Points[highlightColumnIndex].BackHatchStyle = ChartHatchStyle.None;
}
Change chart1 to your chart's name, and change highlightColumnIndex to match the index of the column you want to highlight.
Hope this helps :)
I have a DataGrid that is populated in Codebehind using its DataContext. So the columns are auto generated and the actual number of columns generated do change.
Ultimately I need to be able to display a barchart in the Cells (col) depending on the value of a cell in another field (Col + 1).
My initial thoughts are to add a rectangle and change its width to the percentage of the cell width based on the value in col + 1 - but I am failing to find where to start doing this entirely in code behind.
Has anyone done this or have any advice that might help me get to what I am looking for please?
I can give more information if required.
EDIT:
As Requested, I thought I would try and visualize what I am after better. So, my Datagrid is populated with data similar to the following:
where there are 3 sets of 2 columns (a Perc & Result column for 1, 2 & 3... This number could be up to anything!). Now, the value in the Perc column is referenced to conditionally control the style of rectangles that sit in the respective Result columns (in this example I am using colours to represent the percent. In reality I am looking to use the perc value to set the width of the coloured rectangle in the Datagrid cell to give a barchart appearance).
Finally, I will hide all the Perc columns so the results will look like:
Does that mke any more sense... I hope I havent confused things further??
I'm creating a trial project wherein my window has two grids, left grid is sort of a table that has labels and textboxes each row and asks for a specific part of the invoice like item, name, address stuff like that and the right grid is to show a preview of the invoice that the left side is creating.
I thought about using a document viewer on the right side but I thought that anything I open there would be static and if I put values on the textboxes on the left grid, it wouldn't matter since I opened a standalone document to view on the right grid.
I thought about just creating a table out of the right grid and have the default values and populate the other ones when a user types something on the textbox and make it function as the preview but then I don't know how would I go about and printing it and also, it has about 45 rows which I couldn't fit in the grid without it being unreadable (because I had to cram 45 rows of data inside that small grid)
So is there a tool in the toolbox that could potentially create a interact-able grid? I tried the grid control but I can't seem to only make it show 4 columns because that's all I need, I don't want it to show E and the rest of the alphabet because I want it to resize accordingly with only 4 columns to make it more readable.
Oh and I also have devexpress installed so you guys could also recommend something I can use from there. Thank You.
I think this is the best solution since it does what I wanted it to do.
I created a scroll view and placed a grid inside it then set the length accordingly to show it in a reasonable size and let the scroll bar do its magic for me to see the rest of the grid without compromises of the content's size.
As the subject says I want to insert an image into the 2nd column of grid
defined with 2 columndefintions.
Programmatically that is???
I cannot see how to select the column using grid.Children.insert(1, img)
does not work.
Malcolm
Image imgControl = new Image();
Grid.SetColumn(imgControl, 1);
gridContainer.Children.Add(imgControl);
Objects contained in a grid are positioned based on the attached dependency properties Column Row ColumnSpan and RowSpan which are set as shown above.
The row/column index on an element in WPF is an attached property. You set it using a static method on Grid, like this:
Grid.SetColumn(img, 1);
More info here, and more about attached properties here.