How to set DataGridView cell formatting - winforms

I have a winform with a datagridview.
I read a text file as data for the datagridview and in two columns I have values as 6.5
But when I enter the value 7,5 it changes it to 75.
How do I fix this so when I enter 7,5 it should change to 7.5.
If I enter 7.5 it works just fine.
B.t.w I'am from Denmark if that could help. :)
I tried to replace comma with dot in CellEndEdit and CellLeave
I tried this code.
DataGridViewTextBoxCell cell = DataGridViewTextBoxCell)
cell.Value = cell.FormattedValue.ToString().Replace(",",".);
But that did absolutely nothing.

Related

How to stop Windows Forms label text from rearranging itself

Today I tried using Windows Forms for the first time, which went pretty smoothly until I tried setting the text of a label to "0 lines", which was displayed as "lines 0" in the actual program. I tried a couple of other inputs for the Text property, and it seems the leading number in the label is always moved to the back. I couldn't find any property in the label describing some sort of numerical formatting, so I was wondering were this rearranging came from and what I could do to disable it. Thanks in advance!
screenshot of the input
screenshot of the result
As CodeCaster said in their comment, I simply had to change the RightToLeft property.

certain special characters (ie '<>' or '=>') the data gets converted to & format when pasted into cell in telerik grid view

When I paste a value into a cell that has a special character ( > or <= ) it looks fine, but when they close and reopen the grid it shows up with the &
This is happening in telerik grid view control for winforms.And the cell in inserted into database which column is nvarchar().
Like I paste <10 and it converted to <10

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

Create a table with a color background in SSRS

I need to modify a report in SSRS 2008 that displays a value using a table representation as follows.
The accepted value range is 1-7 and the table changes the background color of the cell in the table. I need to be able to modify the color of the color according to some parameter. I reviewd the code and the report was done by creating 7 images -- with the different bachgrounds -- and hiding all images but the one that matches the prarameter value.
I was thinking on using an HTML table to achive this, but the I found out SSRS does not support the table tag. Any ideas on this??
You can set up BackgroudColor property of the table cell using expression. In the expression return the proper color code based on your parameter, for instance
=Switch(Parameters!yourParam.Value=1, "Red",
Parameters!yourParam.Value=2, "Blue"
...)
I figured it out.
I added 7 Textboxes to the report. I aligned them and set the border values and text to look like the image above. Then, set the color property to something similar to this.
=IIf(Fields!RangeParameter.Value=2,Parameters!ColorParameter.Value,"Transparent")
=iif(RowNumber(Nothing) Mod 2, "#eefafd", "White")

VB 2008 or VB 2010 Dataset help

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

Resources