I have a series of RadioGroups with two options (Radios) 'Yes' and 'No'. I would like to make the RadioGroup required such that one of the options need to be selected.
I can set the required property of each Radio to 'true' but then both must be selected.
How do I achieve this using the DocuSign Api?
---- EDIT
This appears only to be possible using the form designer. The API appears unable to handle this requirement currently.
I've used the designer to create a template and I'm able to achieve making a radio group required with needing to pre-fill an option (which results in a poor user experience and a high chance of inaccurate data).
RadioGroupTabs = new List<RadioGroup>
{
new RadioGroup
{
DocumentId = "1",
RecipientId = "1",
GroupName = "InvestedInEISFundBefore",
RequireAll = "true",
Shared = "true",
Radios = new List<Radio>
{
new Radio
{
PageNumber = "7",
XPosition = "490",
YPosition = "277",
TabOrder = "17",
Value = "Yes"
},
new Radio
{
PageNumber = "7",
XPosition = "480",
YPosition = "277",
TabOrder = "18",
Value = "No"
}
}
}
}
I think what you want is to use the Select = true; in one and Selected = false in the other. The radioGroup automatically has logic to require exactly one radio button to be selected (thus it's not a checkbox, but a radio button!) so all you have to decide is how is the default state when the user just opens the envelope. Hope this makes sense.
Related
I'm having an issue where buttons and actions in ms teams adaptive cards won’t wrap text inside the action button. The button UI is completely broken even if we are applied " full: width" in MS Team. I know the "Wrap: true || false" we can add inside the adaptive card body or title of the textblock, Is there any other way to handle this type of scenario in the action button title in MS Team channel.
The following code we are using for the adaptive card implementation.
public static Attachment ChoiceMenu(string channelType, string text, List buttons, string subCategory = null)
{
var menuCard = new AdaptiveCard("1.2");
if(!string.IsNullOrEmpty(subCategory))
{
menuCard.Body.Add(new AdaptiveTextBlock()
{
Text = subCategory,
Size = AdaptiveTextSize.Large,
Wrap = true,
});
}
menuCard.Body.Add(new AdaptiveTextBlock()
{
Text = text,
Wrap = true,
});
foreach (var button in buttons)
{
var columns = new AdaptiveColumnSet();
menuCard.Body.Add(columns);
var userCategory = new AdaptiveColumn();
columns.Columns.Add(userCategory);
var actionType = new AdaptiveActionSet();
userCategory.Items.Add(actionType);
var submitAction = new AdaptiveSubmitAction()
{
Title = button,
Id = button
};
if (channelType == Channels.Msteams)
{
submitAction.Data = new AdaptiveCardDataObjectForTeams()
{
MsTeams = new MsTeamsObject()
{
Type = ActionTypes.MessageBack,
DisplayText = button,
Text = button
}
};
}
else
{
submitAction.Data = button;
}
actionType.Actions.Add(submitAction);
}
return new Attachment()
{
ContentType = AdaptiveCard.ContentType,
Content = menuCard
};
}
Platform
Web ( MsTeams Web http://teams.microsoft.com ) Microsoft Teams
Version 1.4.00.32771 (64-bit). It was last updated on 12/15/2021.
Adaptive Card Version
1.2
As per the Format cards in Microsoft Teams docs,
Cards support formatting in the text property only, not in the title
or subtitle properties.
Note: The Action Button text is in the title property, This is the reason we cannot do any formatting for it. So there is no way to wrap text in the Action Button.
Alternate Solution:
We have changed the MS Team title of the button using the substring concatenation, hereafter the particular character will display "...", So this way we can alternatively fix this issue.
submitAction.Title = button.Length > 50 ? string.Concat(button.Substring(0, 50), "...") : button;
Output:
Reference:
Github discussion
Apart from using full width property in Adaptive card, there doesn't seem to be any way to increase the size of actionable buttons in adaptive card in order to fit the text/title properly.
"msteams": {
"width": "Full"
}
I'm using "microsoft bot builder" library to build a bot in c#.
I have a card that contains an AdaptiveSubmitAction button which will present a new card on click.
I want to disable the submit button once its activated.. how would that be possible?
This is a part of my code:
////// Submit and Finish button ///////
card.Body.Add(new AdaptiveColumnSet()
{
Columns = new List<AdaptiveColumn>()
{
new AdaptiveColumn()
{
Width = "auto",
Items = new List<AdaptiveElement>()
{
new AdaptiveActionSet()
{
Actions = new List<AdaptiveAction>()
{
new AdaptiveSubmitAction()
{
Title = "Submit",
Id = "Submit",
//from the data you can trigger actions
//e.g.:
Data = new {isDone = false, deleteCrit = false}
},
}
}
}
},
new AdaptiveColumn()
{
Width = "auto",
Items = new List<AdaptiveElement>()
{
new AdaptiveActionSet()
{
Actions = new List<AdaptiveAction>()
{
new AdaptiveSubmitAction()
{
Title = "End",
Id = "Finished",
Data = new {isDone = true, deleteCrit = false}
}
}
}
}
},
}
});
Any help is appreciated!
What you're asking for is impossible because neither Adaptive Cards nor Teams has a concept of a double click when it comes to submit actions. If you were using Web Chat then you might be able to build a custom solution but Teams does not allow for that kind of customizability. If you need a submit action to function in multiple possible ways then I recommend using two different submit actions instead.
You can send feedback to Teams through the Teams app directly or you can submit feature requests in the Teams docs repo or the Adaptive Cards repo.
Yes this should be possible, I believe you can update the Adaptive card view after the first click with only change in view being that the button will be in disabled view. Not only this you can make any change in the card and it will retroactively refresh the view of that card ID. For usage, see context.updateactivity and it's implementation details.
I have the following code which displays a dropdown list of selectable items in a propertygrid which generally works fine. However, the dropdown allows the items within the dropdown to be edited which causes an error on 'System.ComponentModel.EnumConverter.ConvertFrom' as its not a valid enum. For example, Option1 can be changed to OptionABC1 which I want to prevent.
There is a flag on PropertyStoreItem to set it to read only but this prevents the whole property being changed rather than preventing editing of the dropdown items.
How do I make the dropdown non-editable but still allow the fixed list to be selected? It might be a property on the propertygrid I need to change but cannot find it.
[Flags]
Public Enum SomePropertyTypes
{
Option1 = 1,
Option2 = 2,
Option3 = 4,
Option4 = 8,
Option5 = 16,
Option6 = 32
}
public partial class AddSomePropertyForm : RadForm
{
private RadPropertyStore store;
Public AddSomePropertyForm()
{
InitializeComponent();
this.store = this.CreatePropertyStore();
this.radPropertyGrid1.SelectedObject = store;
}
private RadPropertyStore CreatePropertyStore()
{
RadPropertyStore somePropertyStore = new RadPropertyStore();
PropertyStoreItem somePropertyType = new PropertyStoreItem(typeof(SomePropertyTypes), "PropertyName", SomePropertyTypes.Option1, "Property Info", "Group1", false);
somePropertyStore.Add(somePropertyType);
return somePropertyStore;
}
}
You should customize the drop down editor behavior by using the EditorInitialized event.
void radPropertyGrid1_EditorInitialized(object sender, PropertyGridItemEditorInitializedEventArgs e)
{
PropertyGridDropDownListEditor editor = e.Editor as PropertyGridDropDownListEditor;
if (editor != null)
{
editor.DropDownStyle = RadDropDownStyle.DropDownList;
}
}
Here is an article on the matter: link
Set the combobox' DropDownStyle property to ComboBoxStyle.DropDownList - it sounds that is is currently set to ComboBoxStyle.DropDown, which allows editing.
Refer to ComboBoxStyle Enumeration
I create a form in run-time from some parameters in a list of fields.
List<Fields> lstFields = new List<Fields>()
{
new Fields(){ FieldType = Fields.fieldTypes.INPUT, Info = "Some Info", Label = "first", Mandatory= true},
new Fields(){ FieldType = Fields.fieldTypes.CHK, Info ="Some Info", Label="Second",
Items = new List<String>(){"item1","item2","item3","item4"} },
new Fields(){ FieldType = Fields.fieldTypes.INPUT, Label = "Name", Mandatory= true},
new Fields(){ FieldType = Fields.fieldTypes.INPUT, Label = "Surname", Mandatory= true},
new Fields(){ FieldType = Fields.fieldTypes.COMBO, Label = "City", Mandatory = false,
Items = new List<String>(){"item1","item2","item3","item4"}}
}
I create my fields in a foreach statement:
foreach (Fields fd in lstFields)
{
[...]
switch (fd.FieldType)
{
case Fields.fieldTypes.INPUT:
TextBox currentTB = new TextBox(); //It violates MVVM pattern :(
content.Add(currentTB);
[...]
break;
[...]
default:
break;
}
}
}
I need a form validation strategy. All the strategies that I know are based on the binding. The problem is that I can not bind the property because I create the controls dinamically. I would like to solve the problem following the MVVM design pattern.
You say you want to solve it using MVVM yet you're flagrantly violating it already by creating view elements in code. What you should be doing is creating view models to represent the GUI items you want to create, displaying them in an ItemsControl and using a combination of DataTemplates and Triggers to automatically create the view controls for you. By doing that you ensure that everything is data bound and that you adhere properly to MVVM; data validation is then done as it is in any other MVVM app.
As it turns out I answered a question just the other day and posted code showing exactly how to do this.
I have 100 sequential buttons and checkboxes showed in a Windows Forms application, and a database where some numbers are saved.
My aim is to hide the buttons and checkboxes according to the number saved in the database.
For example, in my database I have 4 numbers: 2, 4, 9, and 10. So I want to hide button2, checkbox2, button4, checkbox4, button9, checkbox9, button10, checkbox10.
Here's what I tried:
SqlCeCommand cmnd = con.CreateCommand();
cmnd.CommandText = "SELECT * FROM register_db WHERE semester = #s AND department = #d AND course = #c";
cmnd.Parameters.AddWithValue("#s", semester);
cmnd.Parameters.AddWithValue("#d", department);
cmnd.Parameters.AddWithValue("#c", course);
SqlCeDataReader rd = cmnd.ExecuteReader();
while (rd.Read())
{
string number = rd[0];
button[number].hide();
checkbox[number].hide();
// these are the main things that I didn't know how to do
}
Assuming your controls are named like that, you can access them through the form’s Controls collection:
string number = rd[0];
this.Controls["button" + number].Hide();
this.Controls["checkbox" + number].Hide();
But you should really put them in a separate list, and probably group them into panels in a StackedPanel, or a CheckedListBox.
All Windows Forms controls have a .Hide() method. The code is case-sensitive, so you're not calling it correctly. It needs to be capitalized:
button[number].Hide();
checkbox[number].Hide();
Alternatively, you can set their .Visible property:
button[number].Visible = false;
checkbox[number].Visible = false;
Or are you having trouble with the array of controls? Names like button1, button2, etc. aren't particularly meaningful in most cases. But if your controls are indeed meant to be part of an ordered collection of controls, you can probably just create a collection on your form to represent them:
protected IList<Button> Buttons
{
get
{
return new List<Button>
{
button1, button2, button3; // etc.
};
}
}
Accessing the numeric values in the names themselves would otherwise be a job for reflection, which in many cases isn't really the direction you want to go. It's better to build a structure which meets your needs than to circumvent a structure which doesn't.
With this you can access the controls as an array:
Buttons[number].Hide();
Checkboxes[number].Hide();
You can take it a step further and combine the two, since they pair together. Something like this:
private class ControlGroup
{
public Button Button { get; set; }
public CheckBox CheckBox { get; set; }
public void Hide()
{
this.Button.Hide();
this.CheckBox.Hide();
}
}
(You can add further error checking within that class to guard against nulls, etc. Probably give the class a more meaningful name, too.)
Then your collection becomes:
protected IList<ControlGroup> ControlGroups
{
get
{
return new List<ControlGroup>
{
new ControlGroup { Button = button1, CheckBox = checkbox1 },
new ControlGroup { Button = button2, CheckBox = checkbox2 },
new ControlGroup { Button = button3, CheckBox = checkbox3 }
// etc.
};
}
}
This keeps things logically grouped together where appropriate into a smarter data structure, which makes the calling code easier:
ControlGroups[number].Hide();