I've created a TextBox in which currency values have to be entered but now I am not able to enter .(dot) in the textbox for decimal values. I have written the code in Text_changed event.
The code
int cursorLocation = ((TextBox)(sender)).SelectionStart;
string inputval = ((TextBox)sender).Text;
inputval = inputval.Replace("*", "");
inputval = inputval.Replace("#", "");
inputval = inputval.Replace(",", "");
inputval = inputval.Replace(" ", "");
inputval = inputval.Replace("-", "");
Decimal inputval1 = Convert.ToDecimal(inputval);
((TextBox)sender).Text = inputval1.ToString("###,###");
cursorLocation = ((TextBox)(sender)).Text.Length;
//((TextBox)sender).Text = inputval;
((TextBox)(sender)).SelectionStart = cursorLocation;
This is the problem
((TextBox)sender).Text = inputval1.ToString("###,###");
Whenever you enter new character, the whole textbox.text gets overwritten with the new text in the format ###,###
I just did this under textchanged event and this worked,
try
{
string value = TextBox.Text.Replace(",", "");
long ul;
if (long.TryParse(value, out ul))
{
TextBox.TextChanged -= TextBox_TextChanged;
TextBox.Text = string.Format("{0:#,#}", ul);
TextBox.SelectionStart = TextBox.Text.Length;
TextBox.TextChanged += TextBox_TextChanged;
this.TextBox.MaxLength = 10;
}
}
catch { }
Related
I'm generating an asp:CheckBox dynamically and I need to validate that it is checked with a CustomValidator().
private void AddCheckBox(HtmlGenericControl newDiv, AdditionalFields field)
{
var additionalFieldDiv = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
additionalFieldDiv.Attributes.Add("class", "additional-field-row");
var additionalLabel = new RadLabel();
additionalLabel.Text = field.Label;
additionalLabel.ID = "AdditionalLabel" + field.ControlId;
additionalLabel.CssClass += "title ";
additionalLabel.Width = new Unit(field.LabelWidth ?? 175);
if (field.Required??false) additionalLabel.CssClass += "additional-field-required";
var additionalField = new System.Web.UI.WebControls.CheckBox();
additionalField.ID = "AdditionalField" + field.ControlId;
additionalField.CssClass += "additional-field-checkbox";
additionalField.Width = new Unit(field.Width ?? 200);
var customValidator = new CustomValidator();
customValidator.ID = "CustomValidator" + field.ControlId;
//customValidator.ClientValidationFunction = "CheckBoxValidation(AdditionalField"+ field.ControlId +")";
customValidator.ControlToValidate = "AdditionalField" + field.ControlId;
customValidator.ErrorMessage = string.IsNullOrEmpty(field.ErrorMessage) ? field.Label + " required" : field.ErrorMessage;
customValidator.CssClass += "additional-fields-validator";
customValidator.Display = ValidatorDisplay.Dynamic;
customValidator.ValidationGroup = "valGroup";
customValidator.EnableClientScript = true;
newDiv.Controls.Add(additionalFieldDiv);
additionalFieldDiv.Controls.Add(additionalLabel);
additionalFieldDiv.Controls.Add(additionalField);
if (field.Required ?? false)
{
additionalFieldDiv.Controls.Add(customValidator);
}
}
I get an error if I try to use customValidator.ControlToValidate = "AdditionalField" + field.ControlId;
Control 'AdditionalField9' referenced by the ControlToValidate property of 'CustomValidator9' cannot be validated.
I have several other controls on the page that are in the validation group "valGroup" and I like the CheckBox validated client side. If I can't use the ControlToValidate property do I need to use JavaScript, and if so how do I pass the ID of the CheckBox to validate?
<script type = "text/javascript">
function ValidateCheckBox(sender, args) {
if (document.getElementById("<%=AdditionalField9.ClientID %>").checked == true) {
args.IsValid = true;
} else {
args.IsValid = false;
}
}
</script>
Hope you can help
I've been racking my brain now for a while trying to figure out away to get a typing animation on a watchface. What I'm struggling to do is get it to work as it needs to be printed on a canvas and as it doesn't extend activity some of the standard java solutions just don't work. I've got it working only it's rather slow, jumpy and sometimes will skip letters, I doubt I've done it correctly but this is my solution:
Int textanimation = 0;
String text_1 = "y";
String text_2 = "e";
String text_3 = "s";
Then in the ontap function I've added:
textanimation = 0;
Thread.sleep(100);
textanimation =1;
Thread.sleep(200);
textanimation = 2;
Thread.sleep(300);
textanimation = 3;
Finally in the canvas void
If(textanimation == 0){
String text_1 = "";
String text_2 = "";
String text_3 = "";
} else If(textanimation == 1){
String text_1 = "y";
String text_2 = "";
String text_3 = "";
} else If(textanimation == 2){
String text_1 = "y";
String text_2 = "e";
String text_3 = "";
} else If(textanimation == 3){
String text_1 = "y";
String text_2 = "e";
String text_3 = "s";
}
String tagtxt = mAmbient
? String.format(text_1+text_2+text_3)
: String.format(text_1+text_2+text_3);
Canvas.Drawtext(tagtxt,mxoffset,myoffset,paint);
Is what I'm trying to do actually possible on watchfaces? Or am I stuck with a slow animation. am I looking at this completely wrong (probably) I appreciate any help thank you.
Solved my solution was fine. Just the watch face was only allowing seconds not milliseconds.
I want to mark each CharacterStyle in the document by placing an achored text frame above each text/word. I am quite new to scripting in indesign, so any help is much appreciated.
Here is the expected output:
I found a solution to this, and for those who might encounter the same problem as me here is my code :
app.findChangeGrepOptions.includeFootnotes = false;
app.findChangeGrepOptions.includeHiddenLayers = false;
app.findChangeGrepOptions.includeLockedLayersForFind = false;
app.findChangeGrepOptions.includeLockedStoriesForFind = false;
app.findChangeGrepOptions.includeMasterPages = false;
app.findGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences.appliedCharacterStyle = style;
app.findGrepPreferences.findWhat = ".+";
var found_item = doc.findGrep();
var res_count = found_item.length;
if(res_count > 0){
var found_text = found_item[0].paragraphs.firstItem();
var insertion_character = (found_text.characters.lastItem().index);
var check_insertion_character = insertion_character + 1;
var alt_insertion_character = (found_text.characters.firstItem().index);
var the_story = found_text.parentStory;
try{
app.selection = the_story.insertionPoints[check_insertion_character];
app.selection = the_story.insertionPoints[alt_insertion_character];
}catch(err){
alert(err);
}
var the_anchored_frame = app.selection[0].textFrames.add({geometricBounds:["0","0",1,10],anchoredObjectSettings:{anchoredPosition: AnchorPosition.ABOVE_LINE, horizontalReferencePoint: AnchoredRelativeTo.ANCHOR_LOCATION, verticalReferencePoint: VerticallyRelativeTo.TOP_OF_LEADING}});
the_anchored_frame.contents = style;
// the_anchored_frame.appliedObjectStyle = real_anchor_style;
}
Cheers
I'm use TChart version .Net & VS2005.
The problem of adding a point series.
How TChart point series bottom text hide?
Help me please. Thank you. =)
My Code :
private void GridNotch()
{
Steema.TeeChart.Styles.Points NotchPoint = new Steema.TeeChart.Styles.Points();
TChart1.Series.Add(NotchPoint);
Steema.TeeChart.Axis axis = new Steema.TeeChart.Axis();
TChart1.Axes.Custom.Add(axis);
axis.StartPosition = 5;
axis.EndPosition = 5;
axis.Labels.Items.Add(0, " ");
axis.Labels.Items.Add(5000, " ");
axis.Labels.Items[0].Visible = false;
axis.Labels.Items[1].Visible = false;
axis.Title.Caption = "";
axis.Title.Font.Color = Color.Black;
TChart1.Series[TChart1.Series.Count - 1].CustomVertAxis = axis;
if (dt_Notch.Columns.Count == 0)
{
dt_Notch.Columns.Add("Value", typeof(int));
dt_Notch.Columns.Add("Label", typeof(string));
DataRow row;
row = dt_Notch.NewRow();
row["Value"] = "100";
row["Label"] = "B5";
dt_Notch.Rows.Add(row);
}
TChart1.Series[TChart1.Series.Count - 1].XValues.DataMember = "Value";
TChart1.Series[TChart1.Series.Count - 1].YValues.DataMember = "Value";
TChart1.Series[TChart1.Series.Count - 1].LabelMember = "Label";
TChart1.Series[TChart1.Series.Count - 1].DataSource = dt_Notch;
}
My Graph :
Want Graph :
I see you are assigning the "B5" in your code:
row["Label"] = "B5";
You can either remove that label or force your bottom axis to show values and not labels:
TChart1.Axes.Bottom.Labels.Style = AxisLabelStyle.Value;
I have an Excel File which serves as a template for my Excel work and I want to programatically fill this template with data.
When I create a row and an accompanying cell and set a border for the newly created cell, the whole sheet is assigned this border. Naturally, I only want the single cell to have that border. Here is the code:
string path = Application.StartupPath + "\\" + "Excels\\myTemplate.xls";
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
HSSFWorkbook templateWorkbook = new HSSFWorkbook(fs, true);
HSSFSheet sheet = templateWorkbook.GetSheet("sheet2");
int rowIndex = 3;
var row = sheet.CreateRow(rowIndex);
int i = 0;
string zoneNo;
string SubsidiaryCode = string.Empty;
foreach (DataRow r in dtBill.Rows)
{
SubsidiaryCode = (r["SubsidiaryCode"].ToString().Trim());
zoneNo = (r["ZoneNO"].ToString().Trim());
HSSFCell cell = (HSSFCell)row.CreateCell(i);
cell.SetCellValue("Zone " + zoneNo + "-code :" + SubsidiaryCode);
cell.CellStyle.BorderBottom = HSSFCellStyle.BORDER_MEDIUM;
i++;
row.CreateCell(i).SetCellValue(r["Date"].ToString().Trim());
row.CreateCell(i).CellStyle.BorderBottom = HSSFCellStyle.BORDER_MEDIUM;
i++;
rowIndex++;
row = sheet.CreateRow(rowIndex);
i = 0;
}
sheet.ForceFormulaRecalculation = true;
I found the answer
var row = sheet.CreateRow(rowGlobal);
HSSFCellStyle style1 = templateWorkbook.CreateCellStyle();
style1.BorderRight = HSSFCellStyle.BORDER_MEDIUM;
style1.BorderBottom = HSSFCellStyle.BORDER_MEDIUM;
style1.Alignment = HSSFCellStyle.ALIGN_CENTER;
//style1.FillPattern = HSSFCellStyle.SOLID_FOREGROUND;
//style1.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.GREEN.index;
HSSFFont font1 = templateWorkbook.CreateFont();
//font1.Color = NPOI.HSSF.Util.HSSFColor.BROWN.index;
font1.FontName = "B Nazanin";
style1.SetFont(font1);
cell = row.CreateCell(2);
cell.SetCellValue(0);
cell.CellStyle = style1;