I want a decimal input column in wingrid prefixed with $ symbol.
Please find the below picture for reference
Hi,
You can do with using the Format property on the column. Assuming that the DataType of the column is a numeric type, like decimal / currency, you could do something as simple as this:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band = layout.Bands[0]; band.Columns["Decimal 1"].Format = "c"; }
The "c" format will format the value as currency using the current system settings. For other number format options, check out Microsoft's documentation:
Standard Numeric Format Strings
Custom Numeric Format Strings
Thanks!
I have tried this code but it doesn't work, I want to have 2 decimals with $ prefixed.
Private Sub ugMainManageGangMembers_InitializeLayout(sender As Object, e As InitializeLayoutEventArgs) Handles ugMainManageGangMembers.InitializeLayout e.Layout.Bands(0).Columns("GangLaborId").Hidden = True e.Layout.Bands(0).Columns("Title").Width = 150 e.Layout.Bands(0).Columns("Reg.$/hour").Format = "c"
End Sub
Please find attachment
Hi Vijay,
The screen shot you have here shows the dollar sign in every cell except the one being edited. Format does not (and cannot) apply to the cell being edited.
If you want a dollar sign in the editing cell, then the only way to do that is with a mask.
band.Columns["Decimal 1"].MaskInput = "$nn.nn";
Note that this will limit the user to a certain number of digits before (and after) the decimal point. But there is no way around that. You will need to specify a mask that has enough digits for any of the values in your column.
Thanks Mike! That's clear