Insert hyperlink with linkText at current caret position in richtextbox WPF - wpf

I want to insert a hyperlink with displayText into a richtextbox at the current caret position, I am displaying a popup window for the user to enter the linkURL and the linkText when the user clicks on the Ok button the hyperlink with the display text should be inserted at the current caret position in the RichTextBox.
Thanks in advance.

Test This Code
Hyperlink link = new Hyperlink();
link.IsEnabled = true;
link.Inlines.Add(" Microsoft ");
link.NavigateUri = new Uri("http://www.microsoft.com");
var allRang = new TextRange(Rich.Document.ContentStart,Rich.Document.ContentEnd);
if (allRang.Start.Parent is Run)
{
var run = allRang.Start.Parent as Run;
var runBefore =
new Run(new TextRange(run.ContentStart, Rich.CaretPosition).Text);
var runAfter =
new Run(new TextRange(Rich.CaretPosition, run.ContentEnd).Text);
if (allRang.Start.Paragraph != null)
{
allRang.Start.Paragraph.Inlines.Add(runBefore);
allRang.Start.Paragraph.Inlines.Add(link);
allRang.Start.Paragraph.Inlines.Add(runAfter);
allRang.Start.Paragraph.Inlines.Remove(run);
}
}

Related

How to switch in tabs of popup

enter image [enter image description here]1description here hi when i give details and click on button one popup appears which is having two tabs how to switch between those tabs?
Util.NavigateToLoginPage(ref Driver);
HomeWf.Login(Driver, Username, Password);
var homePage = new PrimaryNavigation(Driver);
homePage.ClickOnMainNavigators(Driver, MainNavigation.Products);
homePage.ClickOnSubMenuOptions(Driver, SubMenuLinks.Products.AddNewProduct);
var bulndlepage = new ProductHomePage(Driver);
bulndlepage.LnkBundleProduct.Click();
//bulndlepage.TxtBrowseNode.SendKeys("Mobile Phones");
bulndlepage.SelectCategory(Driver, "Books"
Console.WriteLine("TxtTitle PRINTED");
bulndlepage.TxtSku.SendKeys("6701");
Console.WriteLine("TxtSku PRINTED");
bulndlepage.ChkCod.Click();
Console.WriteLine("ChkCod PRINTE
bulndlepage.ChkOffline.Click();
Console.WriteLine("ChkOffline PRINTED");
bulndlepage.BtnSaveNext.Click();
bulndlepage.BtnSaveNext.Click();
bulndlepage.BtnAssociateProd.Click();
Driver.SwitchTo().Window(Driver.WindowHandles.Last());
You need to stock your first window name and your popup name.
//Click on your PopUp
driver.FindElement(By.CssSelector("input[id*='IdElemToCLick']")).Click();
string LastWindow = null;
string FirstWindow = null;
foreach (var item in driver.WindowHandles)
{
//Stock first window name
if (FirstWindow == null)
{
FirstWindow = item;
}
LastWindow = item;
}
if (LastWindow != null)
{
// Go to PopUp
driver.SwitchTo().Window(LastWindow);
// Do something with this PopUp
[...]
// Go back to Main Page
driver.SwitchTo().Window(FirstWindow);
}
I see the window appears is a Modal window. You can simply get the id/cssSelector/xpath of the tabs and click on them as required.

Devexpress - How to open a form as a tabbed view

I have a Ribbon Form with a treelist on the left so i put a XtraUserControl to insert a DocumentManager in which i would like to add all my tabbed forms (like in Visual Studio).
How can i do this?
Thanks
I suggedt you start from the How to: Display Documents Using a Tabbed UI example. The main idea of this example is that you can add the DocumentManager onto the form and then handle a treelist item's Click to add all needed child forms as MDI-children - the DocumentManager will track all the changes automatically:
Form childForm = new Form();
childForm.MdiParent = this;
childForm.Show();
To read more about the another Document Manager concepts and features please refer to the corresponding documentation articles.
public void Viewchild(Form _form)
{
//Check Before Open
if (!IsFormActive(_form))
{
_form.MdiParent = this;
_form.Show();
}
}
//Check If a Form Is Opened Already
private bool IsFormActive(Form form)
{
bool IsOpened = false;
//If There Is More Than One Form Opened
if (MdiChildren.Count() > 0)
{
foreach (var item in MdiChildren)
{
if (form.Name == item.Name)
{
// Active This Form
xtraTabbedMdiManager1.Pages[item].MdiChild.Activate();
IsOpened = true;
}
}
}
return IsOpened;
}
open form in
Master.frmBranch fb = new Master.frmBranch();
fb.Name = "frmBranch";

Data Grid View Scoll bar issues

I have One Winform.There is one TabContainer inside it in Fill Mode I am adding one another form with group box and DataGridView with dock mode fill as control of tab inside that tab control with dock mode fill.I have set Scroll bar property to both for DataGridView but not able to Show Horizontal.
if (activeForm != null &&
hasReviseAvgDiscountPermission == true)
{
//Add for in tab page.
FrmRePricing reviseAvgDiscount = new FrmRePricing(activeForm, secondaryUser);
if (reviseAvgDiscount.WidgetDataLoaded == true)
{
reviseAvgDiscount.CloseOnEscape = false;
reviseAvgDiscount.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
reviseAvgDiscount.TopLevel = false;
tabPgAvgDiscountRevision.Controls.Add(reviseAvgDiscount);
reviseAvgDiscount.Dock = DockStyle.Fill;
reviseAvgDiscount.Show();
reviseAvgDiscount.Focus();
}
else
{
//Remove tab page if no data found.
tabWidget.TabPages.Remove(tabPgAvgDiscountRevision);
}
this is code to load form as control.and I have data in grid there are show many columns but show intial some columns.

How do I programmatically create a GUI and create it for my windows form?

As above, how do I create buttons or labels programmatically instead of using the drag and drop function?
The following sample is a code for creating a panel.
public Panel createPanel()
{
Panel p = new Panel
{
BorderStyle = BorderStyle.FixedSingle,
Size = new Size(506, 110),
Name = "Panel"
};
Button button = new Button
{
Text = "Clear",
Name = "Button",
Location = new Point(410, 40)
};
p.Controls.Add(button);
return p;
}
Go to YourForm.Designer.cs and see how it's done.
Remember that they're just object members.

Can I put a Button in a RichTextBox in Silverlight 4?

I would like to allow users to put a System.Windows.Controls.Button in the System.Windows.Controls.RichTextBox. The button would do a pre-defined thing.
I figured out how to do this. It's called an InlineUIContainer you can do something like this to get it working. Although it doesn't save it into the Xaml
var p = new Paragraph();
var inlineUIContainer = new InlineUIContainer() { Child = new Button() { Content = "This is a Button!" } };
p.Inlines.Add(inlineUIContainer);
_richTextBox.Blocks.Add(p);

Resources