I'm trying to use the Microsoft ribbon control programatically using C#. Everything is fine but I'm unable to bind the command through the RibbonCommand. Can anyone give me an example of how to do this? My actual code is:
Ribbon rbn = new Ribbon();
RibbonTab file = new RibbonTab();
file.Name = "file";
file.Label = "FILE";
RibbonTab edit = new RibbonTab();
edit.Name = "edit";
edit.Label = "Edit";
RibbonGroupPanel rbgp = new RibbonGroupPanel();
RibbonGroup rbg = new RibbonGroup();
RibbonButton rbtn = new RibbonButton();
rbtn.Content = "New";
RibbonCommand rcomnd = new RibbonCommand();
rcomnd.LabelTitle = "NEW";
rcomnd.ToolTipDescription = "THIS IS NEW";
rcomnd.LargeImageSource = imgSource;
rcomnd.Execute(rbtn, rbtn);
rbtn.IsEnabled = true;
//rcomnd.SmallImageSource = imgSource;
rcomnd.CanExecute +=new CanExecuteRoutedEventHandler(rcomnd_CanExecute);
rcomnd.Executed +=new ExecutedRoutedEventHandler(rcomnd_Executed);
CommandBinding cmdb = new CommandBinding(ApplicationCommands.New);
cmdb.Command = ApplicationCommands.New;
cmdb.Executed +=new ExecutedRoutedEventHandler(cmdb_Executed);
CommandBind.Add(cmdb);
//rcomnd.Executed += new ExecutedRoutedEventHandler(OnAddNewEntry);*/
rbtn.Click +=new System.Windows.RoutedEventHandler(rbtn_Click);
rbtn.Command = rcomnd;
But the bindings are not working and the button is not enabled.
Check this tutorial from the "Adding Commands" section. It may be good to read it from the start.
Related
In FormField "HH" i am trying to make text as link, but it is readed only as string text, it is not clickable.
I use Aspose.Pdf v.11.6.0.
var doc = new Aspose.Pdf.Document(pdfFileStream);
var pdfForm = new Aspose.Pdf.Facades.Form(doc);
pdfForm.FillField("Name", model.Name.ToUpper());
pdfForm.FillField("ISOS", model.NumberISOS.ToUpper());
pdfForm.FillField("Info", dateInfo);
pdfForm.FillField("HH", "http://www.somewebsite.com");
I use this code:
Page page = (Page)doc.Pages[1];
var text = new TextFragment("index");
text.Position = new Position(200, 300);
Aspose.Pdf.WebHyperlink link = new
WebHyperlink("www.google.com");
text.Hyperlink = link;
page.Paragraphs.Add(text);
but new Position(200, 300); values not responding.
Here is my solution, because position does not work, i move the link with margins. This worked for me.
Page page = (Page)doc.Pages[1];
var text = new TextFragment("LINK");
text.Position = new Position(300, 300);
Aspose.Pdf.WebHyperlink link = new WebHyperlink("www.google.com");
text.Hyperlink = link;
text.Margin.Left = -48;
text.Margin.Top = 687;
text.Margin.Bottom = -150;
text.TextState.Underline = true;
text.TextState.FontSize = 11;
text.TextState.ForegroundColor = Aspose.Pdf.Color.DeepSkyBlue;
text.TextState.BackgroundColor = Aspose.Pdf.Color.White;
page.Paragraphs.Add(text);
Form2:
private ToolStripMenuItem mHelp;
private ToolStripMenuItem apProposToolStripMenuItem;
public void intializecomponent()
{
this.mHelp = new ToolStripMenuItem();
this.contentsToolStripMenuItem = new ToolStripMenuItem();
this.apProposToolStripMenuItem = new ToolStripMenuItem();
this.mHelp.DropDownItems.AddRange(new ToolStripItem[2]
{
(ToolStripItem) this.contentsToolStripMenuItem,
(ToolStripItem) this.apProposToolStripMenuItem
});
this.mHelp.Name = "mHelp";
this.mHelp.Size = new Size(44, 20);
this.mHelp.Text = "Help";
this.contentsToolStripMenuItem.Name = "contentsToolStripMenuItem";
this.contentsToolStripMenuItem.Size = new Size(122, 22);
this.contentsToolStripMenuItem.Text = "Contents";
this.contentsToolStripMenuItem.Click += new EventHandler(this.contentsToolStripMenuItem_Click);
this.apProposToolStripMenuItem.Image = (Image) componentResourceManager.GetObject("apProposToolStripMenuItem.Image");
this.apProposToolStripMenuItem.Name = "apProposToolStripMenuItem";
this.apProposToolStripMenuItem.Size = new Size(122, 22);
this.apProposToolStripMenuItem.Text = "About";
this.apProposToolStripMenuItem.Click += new EventHandler(this.apProposToolStripMenuItem_Click);
this.Load += new EventHandler(this.DocumentSpace_Load);
}
How to find apProposToolStripMenuItem on the form? I tried to remove a particular ToolStripMenuItem, but it doesn't work and I can't find apProposToolStripMenuItem.
Form1:
ToolStripMenuItem mi = new ToolStripMenuItem("apProposToolStripMenuItem") { Name = "About" };
mi.DropDownItems.RemoveByKey("About");
You can remove it by name like this:
mHelp.DropDownItems.RemoveByKey("apProposToolStripMenuItem");
You can also remove it directly like this:
var about = mHelp.DropDownItems["apProposToolStripMenuItem"]
mHelp.DropDownItems.Remove(about);
Assuming you have access to the MenuStrip or the ToolStrip on the form, then you can use Descendants extension method to find all items, regardless of its location in hierarchy of menus and its parent item. for example:
var item = menuStrip1.Descendants()
.Where(x => x.Name == "printToolStripMenuItem").FirstOrDefault();
item?.GetCurrentParent().Items.Remove(item);
im really new to c# and Xamarin Forms but can someone please explain to me why I'm getting an error in the last line of code below ?
Visual Studio is indicating a curly red underline on the word Children on the last line of this code indicating that there is some syntax error but I don't see why that is an error since I'm just accessing a member of the class ....
var content = new ContentPage();
content.Title = "Appuler";
Label CompanyName = new Label();
CompanyName.HorizontalTextAlignment = TextAlignment.Center;
CompanyName.Text = "Test";
Button NextPage = new Button();
NextPage.Text = "Next Page";
NextPage.Font = Font.SystemFontOfSize(NamedSize.Large);
NextPage.BorderWidth = 1;
NextPage.HorizontalOptions = LayoutOptions.Center;
NextPage.VerticalOptions = LayoutOptions.CenterAndExpand;
content.Content = new StackLayout();
content.Content.VerticalOptions = LayoutOptions.CenterAndExpand;
content.Content.Children.Add(CompanyName);
Refactor the last few lines to the following
var layout = new StackLayout();
layout.VerticalOptions = LayoutOptions.CenterAndExpand;
layout.Children.Add(CompanyName);
content.Content = layout;
ContentPage.Content does not have that Children property as it is a View. StackLayout, however does have a Children property that can be accessed.
populate the layout control's accessible properties and then assign it to the Content property of the ContentPage.
I am using Adobe Echo Sign API createwidget for signing documents,I want to add editable fields, Like we get when we select "Preview, position signatures or add form fields" here, I have attached the screen shot as well
I have tried using MergeField Info of createwidget but its not creating fields on widget API documentation
Here's my code
WidgetCreationInfo widgetinfo = new WidgetCreationInfo(widgetname, fileInfos);
MergeField[] mergedfields = new MergeField[1];
mergedfields[0] = new MergeField();
mergedfields[0].fieldName = "name";
mergedfields[0].defaultValue = "Salman";
MergeFieldInfo mergedfieldinfo = new MergeFieldInfo();
mergedfieldinfo.mergeFields = mergedfields;
widgetinfo.mergeFieldInfo = mergedfieldinfo;
MergeField[] mergedfields = new MergeField[4];
mergedfields[0] = new MergeField();
mergedfields[1] = new MergeField();
mergedfields[2] = new MergeField();
mergedfields[3] = new MergeField();
mergedfields[0].fieldName = "name";
mergedfields[0].defaultValue = "Your value";
mergedfields[1].fieldName = "your fildname";
mergedfields[1].defaultValue = "Your value";
mergedfields[2].fieldName = "your fildname";
mergedfields[2].defaultValue = "Your value";
mergedfields[3].fieldName = "your fildname";
mergedfields[3].defaultValue = "Your value";
I tried with above code and its working smoothly..
I'm new to Visual Studio and fixing a small bug in an application.
The combo box which exist is editable with DropDown eventhough it is has databinding. Because If I deleted a value, it would not save the change, I made it into a DropDownList; however, now I do not have the option of using null.
I have searched around and have been reading that I can insert an item before databinding.
I have the bits and peices of the codes from different functions for this combo box. Not sure where to exactly make the change.
if someone could point me in the right direction, that'd be great.
private System.Windows.Forms.ComboBox cmbSecCSR;
//----------------
this.cmbSecCSR = new System.Windows.Forms.ComboBox();
//---------------------
// cmbSecCSR
//
this.cmbSecCSR.AccessibleRole = System.Windows.Forms.AccessibleRole.TitleBar;
this.cmbSecCSR.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
this.cmbSecCSR.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
this.cmbSecCSR.DataSource = this.csrBindingSource2;
this.cmbSecCSR.DisplayMember = "Name";
this.cmbSecCSR.FormattingEnabled = true;
this.cmbSecCSR.Location = new System.Drawing.Point(112, 26);
this.cmbSecCSR.Margin = new System.Windows.Forms.Padding(0);
this.cmbSecCSR.MaxDropDownItems = 10;
this.cmbSecCSR.Name = "cmbSecCSR";
this.cmbSecCSR.Size = new System.Drawing.Size(184, 21);
this.cmbSecCSR.TabIndex = 2;
this.cmbSecCSR.ValueMember = "Username";
this.cmbSecCSR.TextChanged += new System.EventHandler(this.comboBox_TextChanged);
this.cmbSecCSR.Enter += new System.EventHandler(this.cmbBox_Entered);
//
// csrBindingSource2
//
this.csrBindingSource2.DataMember = "CSR";
this.csrBindingSource2.DataSource = this.productionDS;
//-------------------------
//loadUnboundData();
cmbSecCSR.DataBindings.Add("SelectedValue", productionMasterBindingSource, "CSR2", true, DataSourceUpdateMode.OnPropertyChanged);
My Problem is similar to this: http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/fa277629-a65b-4799-9400-364f6f771739/
which is why I decided to change it to DropDownList;however, I don't know how to add the NULL Value in the DropDownList as it is bounded.