VB 2008 or VB 2010 Dataset help - database

I have three forms similar to the one in the link.
I want add a Total textbox to every form.
The total will add the values that will be entered in the montant textbox.
So the total will take the specific value of that texbox for all the entries that the user will have and add them.
How I can do so????
Thanks
http://i1006.photobucket.com/albums/af189/diaboloent/OneForm.jpg

Put all the textboxes where the user will enter a value inside a common container like a groupbox or panel control. Then use code like this to total up the values:
Dim sum As Integer = 0
For Each box As TextBox In MyContainer.Controls.OfType(Of TextBox)()
sum += Integer.Parse(box.Text)
Next box
Total.Text = sum.ToString()
You can even get this down to a one-liner:
Total.Text = MyContainer.Controls.OfType(Of TextBox)().Select(Function(s) Integer.Parse(s.Text)).Sum()

Related

Why alternate background color in SSRS on a matrix reflects on more than 1 row

For some reason alternate background in matrix covers more then one row.
My Row Group:
I would expect it to behaive like this:
This is the expression I use:
= IIf(RowNumber(Nothing) Mod 2 = 0, "AliceBlue", "Transparent")
Check this below sample screenshot and steps. It will give desired output
Sample Report Preview
Sample Report Design
Steps :
Create sample matrix report
Create the new column outside the group right
In newly created column's textbox named as txtRowNumber, set the value to RowNumber(Nothing) and column visibility to Hide
In Matrix column's textbox set the fill value to IIF(ReportItems!txtRowNumber.Value Mod 2 =0,"Green","Transparent").
Preview the report and change the design and so on.

How to create little colored shape in a cell that would indicate colors on a chart? SSRS 2012

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)

How To Highlight a Column in a WinForm StackedColumn Chart

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 :)

WPF DataGrid - Adding Rectangles to DataGrid cells in codebehind

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??

Listview image on columns

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...

Resources