How access Text of a textbox in class of stimulsoft file - stimulsoft

I have a function I wrote on stimulsoft report code :
public static ChangeTextBoxValue(string s)
{
return s + " S.T ";
}
And in a textbox in designer I wrote an expression :
{ChangeTextBoxValue(Text1.Text)}
But at preview it return only " S.T " .
I try this too, But it didn't work too:
public static ChangeTextBoxValue()
{
return Text1.Text + " S.T ";
}
By this expression on textbox:
{ChangeTextBoxValue()}

It's impossible to use Text1.Text expression in other component. Because after rendering there are many Text1 componnents on report pages and usually they have different values. Which one should be used?
You should use the same expression as you use in Text1 component. This expression will be calculated for this component.

Related

Button text ">" and "<" is not converting to ">" and "<" in xamarin forms

I just need to display ">" and "<" as button text so I just used &gt with a semicolon and &lt with semicolon but in the UI it is showing the text instead of "<" and ">". But it is working fine in Xaml not in code behind c# file.
Please find the code
CustomButton moveToNewCheckButton = new CustomButton
{
Text = ">",
Style = (Style) Application.Current.Resources["MoveButtonStyle"],
AutomationId = "MoveToNewCheckButton"
};
just use
Text = ">",
In addition to the #Jason answer, you also can use WebUtility.HtmlDecode method. e.g. in case you want to use the same string in both Xaml and C#.
using System.Net;
Text = WebUtility.HtmlDecode(">");

xpages partial - full search

I saw a great tutorial from IBM explaining creating a search modulo into a view panel.
The code from the viewpanel ( search property ) I adjusted:
"(Field txt_autor = \"" + sessionScope.searchAutor + "\")";
}
Is there any chance I can modify the code so that it offers the search results for the partial string matches also, for example: if Autor = Smith and in the string searchAutor = Smit currently I get 0 documents / 0 results. Something like CONTAINS will be useful, if it's possible.
Thanks for your time.
Add a star "*" in front and at the end of every search string like "*Smit*".
Your code would look like this then
tmpArray[cTerms++]= "(Field txt_titlu = \"*" + sessionScope.searchTitle + "*\")";

Delete Selected Text from Textbox and Enter New Char in C#.NET

I am trying to delete selected text from textbox and enter new character in place of it.
For example, if textbox consists of 123456 and I select 345, and press r on the keyboard, it should replace the selected text.
here is my code:
string _selectText = txtCal.SelectedText;
string _text = Convert.ToString(btn.Text);
if (_selectText.Length > 0) {
int SelectionLenght = txtCal.SelectionLength;
string SelectText = txtCal.Text.Substring(txtCal.SelectionStart, SelectionLenght);
txtCal.Text = ReplaceMethod(SelectText, _text);
}
//replace method function
public string ReplaceMethod(string replaceString, string replaceText) {
string newText = txtCal.Text.Replace(replaceString, replaceText);
return newText;
}
Can anyone show me where my mistake is?
The replace-based answer offered above may well replace the wrong instance of the selection, as noted in the comments. The following works off positions instead, and doesn't suffer that problem:
textbox1.Text = textbox1.Text.Substring(0, textbox1.SelectionStart) + textbox1.Text.Substring(textbox1.SelectionStart + textbox1.SelectionLength, textbox1.Text.Length - (textbox1.SelectionStart + textbox1.SelectedText.Length));
The following does what you want and then selects the replacing text :)
string _text = Convert.ToString(btn.Text);
int iSelectionStart = txtCal.SelectionStart;
string sBefore = txtCal.Text.Substring(0, iSelectionStart);
string sAfter = txtCal.Text.Substring(iSelectionStart + txtCal.SelectionLength);
txtCal.Text = sBefore + _text + sAfter;
txtCal.SelectionStart = iSelectionStart;
txtCal.SelectionLength = _text.Length;
Try this instead
if (textbox1.SelectedText.Length > 0)
{
textbox1.Text = textbox1.Text.Replace(text1.Text.Substring(textbox1.SelectionStart, textbox1.SelectionLength), btn.Text);
}
This is essentially the same as other answers, but formatted differently using C# 6.0.
// If there is selected text, it will be removed before inserting new text.
// If there is no selected text, the new text is inserted at the caret index.
string before = textBox.Text.Substring(0, textBox.SelectionStart);
string after = textBox.Text.Substring(textBox.SelectionStart + textBox.SelectedText.Length);
textBox.Text = $"{before}{insertText}{after}";
textBox.CaretIndex = $"{before}{insertText}".Length;
Note that I set the CaretIndex to a new position after changing the text. This may be useful since the caret index resets to zero when changing the text like this. You may also want to focus the textbox to draw the user's attention to the change and allow them to know where the caret currently is.

Sharepoint 2010 How to use "File Size" column value in a formula?

I am trying to use "File Size" (aka "FileSizeDisplay") in a Calculated column formula.
"File Size" is an existing column (default SP not custom).
But is not available in the "Insert Column" list of any library.
And SP displays an error message that states it does not exist if it is added to a formula manually as either [File Size] or [FileSizeDisplay].
All I want to do is inform a user that an image is too big. Not trying to prohibit file size upload or anything technical like that. Just want a Calculated column to display a message.
If the column value was available the following would work:
=IF([File Size]>50000,"Image is too big","Image is sized correctly")
or
=IF([FileSizeDisplay]>50000,"Image is too big","Image is sized correctly")
Any one know why this column is not available?
Cheers
You'll want to get the file size first: get file size then you can display of message in a pop up or how ever you'd like
using System;
using System.IO;
class Program
{
static void Main()
{
// The name of the file
const string fileName = "test.txt";
// Create new FileInfo object and get the Length.
FileInfo f = new FileInfo(fileName);
long s1 = f.Length;
// Change something with the file. Just for demo.
File.AppendAllText(fileName, " More characters.");
// Create another FileInfo object and get the Length.
FileInfo f2 = new FileInfo(fileName);
long s2 = f2.Length;
// Print out the length of the file before and after.
Console.WriteLine("Before and after: " + s1.ToString() +
" " + s2.ToString());
// Get the difference between the two sizes.
long change = s2 - s1;
Console.WriteLine("Size increase: " + change.ToString());
}
}

gridview replace string from a boundfield

I have a SPGridView that displays items from a list (using spboundfield).
The multi-lookup fileds in my SPGridview the filter values of a lookupfield appear in this format:
{id};#{Value}
How do I replace the id;# from the field?
Here is how I solved this issue. (NOTE i had to put a dot before asp and itemtemplate for this post. remove those dots)
asp:TemplateField HeaderText="Campaign Members">
ItemTemplate>
%# RemoveCharacters(Eval("CampaignMembers").ToString())%>
/ItemTemplate>
/asp:TemplateField>
// Make sure declare using System.Text.RegularExpression;
protected string RemoveCharacters(object String)
{
string s1 = String.ToString();
string newString = Regex.Replace(s1, #"#[\d-];", string.Empty);
newString = Regex.Replace(newString, "#", " ");
return newString.ToString();
}

Resources