Hi i want to set a text to three textblocks from service url
"http://www.findyourfate.com/rss/yearly-horoscope.asp?sign=Aries",which is a single string,
I just want to split three strings and setting the text to three textblocks of
text1,text2,text3.idone setting why i'm splitting means in single textblock not displaying full content because of this reason i thought to split into three strings.for first text block what i neede to display has been done sucessfulyy ,I tried to set for rest of the textblock but i'm stuck please help me to resolve this issue.I'm begginer to this windows 8 development please help me.
try
{
XDocument xmlDoc = XDocument.Parse(e.Result);
var result = xmlDoc.Descendants("channel");
List<xmlList> _xmList = new List<xmlList>();
foreach (var item in result)
{
var node = item.Descendants("item");
//XDocument xdoc = XDocument.Load(e.Result);
foreach (var xElememt in node)
{
string description = xElememt.Element("description").Value;
MessageBox.Show("" + description.Length);
string input = description;
int pattern = input.IndexOf("CAREER");
int pattern1 = input.IndexOf("RELATIONSHIP");
int pattern2 = input.IndexOf("FINANCE");
string str1 = input.Substring(0,pattern);
string str2 = input.Substring(pattern,pattern1);
string str3 = input.Substring(pattern2);
text1.Text = str1;
text2.Text = str2;
text3.Text = str3;
}
You could use the String.Split Method in order to split a string.
Reference: C# Split A String By Another String
You don't have need to split the string and also no need to use three textblocks,
You can use RichTextBox control to show the information.
It will show your full content of description
use the bellow code with scrollbar in .xaml page
<ScrollViewer
VerticalScrollBarVisibility="Visible"
ManipulationMode="Control"
Height="400"
Margin="0,0,0,-13" >
<RichTextBox TextAlignment="Justify"
IsReadOnly="True"
Margin="0,0,0,10">
<Paragraph Foreground="#626262"
FontSize="17"
FontStyle="Normal"
FontFamily="Regular" >
<Run x:Name="txtDescription" />
</Paragraph>
</RichTextBox>
</ScrollViewer>
and set the value of description to txtDescription in .xaml.cs file
txtDescription.Text = xElememt.Element("description").Value;
Related
I am declaring an NSMutable Attributed String and appending different attributed strings to it. These attributed string may contain images as NSTextattachments.
var historyText : NSMutableAttributedString = NSMutableAttributedString(string: "")
let imageAttachment = NSTextAttachment()
imageAttachment.image = UIImage(named: "some_image")
imageAttachment.bounds = CGRect(x:0, y:-3.0, width: (imageAttachment.image?.size.width)!, height:(imageAttachment.image?.size.height)!)
let imageString = NSAttributedString(attachment: imageAttachment)
historyText.append(imageString)
I then save this attributed text in core data. But when i retrieve this attributed text from core data, the imageAttachment.bounds are lost.
Please suggest a way to preserve these bounds.
Thanks in advance.
I've got a String full of weblink image (23 links) :
listItem.text = String(item.movieimage);
If I do trace(String(item.movieimage)); the output is :
http://www.thewebsite.nc/Content/images/AFFICHES/xxx_3.jpg
http://www.thewebsite.nc/Content/images/AFFICHES/vaiana.jpg
http://www.thewebsite.nc/Content/images/AFFICHES/tous_scene.jpg
http://www.thewebsite.nc/Content/images/AFFICHES/fits.jpg
http://www.thewebsite.nc/Content/images/AFFICHES/boyfriend.jpg
http://www.thewebsite.nc/Content/images/AFFICHES/sahara2017.jpg
http://www.thewebsite.nc/Content/images/AFFICHES/resident_evil_final.jpg
http://www.thewebsite.nc/Content/images/AFFICHES/raid_dingue.jpg
http://www.thewebsite.nc/Content/images/AFFICHES/passengers2017.jpg
http://www.thewebsite.nc/Content/images/AFFICHES/lego_batman.jpg
http://www.thewebsite.nc/Content/images/AFFICHES/grande_muraille.jpg
http://www.thewebsite.nc/Content/images/AFFICHES/fille_brest.jpg
Know, I've got 9 UILoader on my stage.
So I would like to do
uiloader1.source = item.movieimage[1];
uiloader2.source = item.movieimage[2];
uiloader3.source = item.movieimage[3];
...etc...
How can I do that ?
Thanks
Assuming they're separated by an indent
//Put all the links in an array
var myItems:Array = listItem_txt.text.split("\n");
//You say you only have nine, so only iterate until the 9th
for (var i:int = 0; i < 9; i++)
{
//Also assuming your "uiloader" is a custom class you made with a .source property
this.getChildByName("uiloader" + i).source = myItems[i];
}
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.
I'm trying to get data from a window that has 3 lists (SysListView32).
I do the same on the three of them, both UISpy and Inspect DO see rows and cells in the three of them, but when in code two of them works perfect (Caption="List2" and Caption="List3"), but the third contains ONLY white empty strings.
If I try:
IntPtr PrizeListHandle = Win32Utils.FindWindowByCaption(Lobby, "List1");
IUIAutomationElement dataGridPrizes = autom.ElementFromHandle(PrizeListHandle);
IUIAutomationGridPattern gridPrizes = dataGridPrizes.GetCurrentPattern(10006);
string linea = gridPrizes.GetItem(0, 0).CurrentName;
linea turns to be and empty string, gridPrizes has 17 rows, 3 columns, all cells are empty strings.
If I try:
IntPtr PrizeListHandle = Win32Utils.FindWindowByCaption(Lobby, "List1");
IUIAutomationElement dataGridPrizes = autom.ElementFromHandle(PrizeListHandle);
int propIdClassName = 30004; // UIA_ClassNamePropertyId;
IUIAutomationPropertyCondition conditionListItem = (IUIAutomationPropertyCondition)autom.CreatePropertyCondition(propIdClassName, "list item");
IUIAutomationElementArray children = dataGridPrizes.FindAll(interop.UIAutomationCore.TreeScope.TreeScope_Children, conditionListItem);
int i = children.Length;
i is 0. Why?
It's important to note that when using UISpy it finds EVERYTHING. Also, I have tried both managed an unmanaged version on Automation, with same exact results.
I'm using Windows Server 2008 R2.
Here's a screenshot:
Thank you in advance
You need use ScrollItemPattern.ScrollIntoView() bring into view.
var pattern = (ScrollItemPattern)aeDataGridCell
.GetCurrentPattern(ScrollItemPatternIdentifiers.Pattern);
pattern.ScrollIntoView();
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();
}