How can i change Error message? - spreadsheetgear

I'm using worksheet protection IWorksheet.ProtectContents. If i try to change something there is message: "Locked cells cannot be modified when protection is enabled". So is there a way to change text and title of this message or though hide it?

You can handle the WorkbookView.ShowError(...) event, which would give you the chance to prevent certain error messages from popping up or provide your own custom message. Example:
private void workbookView_ShowError(object sender, SpreadsheetGear.Windows.Controls.ShowErrorEventArgs e)
{
if (e.Message == "Locked cells cannot be modified when protection is enabled.")
{
MessageBox.Show("My custom message");
e.Handled = true;
}
}

Related

ICommand not always firing when tab selected

I have a simple ActionBar with 3 tabs attached. When a tab is clicked, the fragment is inflated and the view shows. The tab being click event is fired using an event. Initially, the first fragment is inflated, but the others respond and inflate if clicked.
If I change the event being fired to an ICommand, only the last fragment is inflated and then if I click on the first tab, that and the last are inflated. Never the second.
My code is this
ICommand TabClicked
{
get
{
return new RelayCommand(() =>
{
tab.TabSelected += (object sender, ActionBar.TabEventArgs e) => TabOnTabSelected(sender, e);
});
}
}
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
fragments.Add(new TODFragment());
fragments.Add(new ConditionsFragment());
fragments.Add(new ResultsFragment());
AddTabToActionBar("Time", Resource.Drawable.crucifix_colour);
AddTabToActionBar("Conditions", Resource.Drawable.weather_colour);
AddTabToActionBar("Results", Resource.Drawable.tod_colour);
}
void AddTabToActionBar(string text, int iconResourceId)
{
tab = ActionBar.NewTab().SetTag(text).SetText(text).SetIcon(iconResourceId);
/* uncomment and comment out one of the two below to see the difference in operation */
tab.TabSelected += TabOnTabSelected;
//tab.SetCommand<ActionBar.TabEventArgs>("TabSelected", TabClicked);
ActionBar.AddTab(tab);
}
void TabOnTabSelected(object sender, ActionBar.TabEventArgs tabEventArgs)
{
var tabNo = sender as ActionBar.Tab;
var frag = fragments[tabNo.Position];
tabEventArgs.FragmentTransaction.Replace(Resource.Id.frameLayout1, frag);
}
Am I missing something fundamental here in the difference between ICommands and Events or is it something else?
I'm using Xam.Android and MVVMLight
I found the answer. When I create the partial class I define the UI objects like this (or something like this at least)
EditText myEditText;
EditText MyEditText = myEditText ?? (view.FindViewById<EditText>(Resources.Id.myEdit);
This is fine, but it does mean that once defined, it doesn't get redefined.
Not a problem if the UI is not really going to change, but every time an action tab is pressed, the fragment is refreshed. Only problem is the Id isn't changing as myEditText is not null.
The answer is add a method in the UI definition code that nulls the objects then in the main code, when the UI disappears, call the nulling method. Everything works then

ReactiveCocoa 4 - Need help on validate input upon button tap

I'm new to ReactiveCocoa, and I'm trying to figure out the syntax for validating form input upon button tap. There are quite a number of sample code for validTextSignal, but most of them either hooked into Action-enableIf, or handle UI bindings directly.
The idea is simple, I have a login screen, with email and password input. What I want is to handle validation upon Login tap to show an UIAlertView (eg. "Please input your email").
Here's what I figured out after awhile, the code works, but I'm not certain whether this should be the way to do it.
self.s_formErrorMessage <~ combineLatest(s_email.producer, s_password.producer)
.map({ (email, password) in
if adminNumber.isEmpty {
return "Please input admin number"
} else if password.isEmpty {
return "Please input password"
}
return ""
})
And here's how I use it, just simply use the value in button TouchUpInside
btn_login.rac_signalForControlEvents(.TouchUpInside).subscribeNextAs { (button: UIButton) in
if !self.viewModel.s_formErrorMessage.value.isEmpty {
self.showAlert("", message: self.viewModel.s_formErrorMessage.value)
}
}
Also, is there anyway we can capture Interrupted event from Action-enableIf false?
Any suggestion for better approach would be much appreaciated.
Cheers
Action use with button for disabled while do request (for example login request). So in this case need disabled button if not valid input.
Or binding error text in prompt text field if not valid.
But if you want just show alert with text error about failed valid fields you cat try this code:
btn_login.rac_signalForControlEvents(.TouchUpInside)
.toSignalProducer().map { [unowned self] _ in
return self.viewModel.s_formErrorMessage.value
}.filter { !$0.isEmpty }
.startWithNext { [unowned self] text in
self.showAlert("", message: text)
}

How to move sliderfield bar as per the values enter in editfield in blackberry?

I know how to fetch values from slider and put values into edit field but
i am not finding anything about moving slider field bar as per the values inserted in edit field?
I use following for getting values from slider field
FieldChangeListener listenerslider1 = new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
try {
if (field == mdrdageslider1) {
int ageslidervalue = mdrdageslider1.getValue();
String strageslidervalue = Integer
.toString(ageslidervalue);
edtmdrdage.setText(strageslidervalue);
}
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (NullPointerException e) {
e.printStackTrace();
}
}
};
but not having any idea of moving scroll bar as per the edit field inserted values?
I think I am missing something here.
I presume what you are calling a slider is the GaugeField in the API. It offers the getValue() method that you have already using. It also offers the setValue() method. So in your EditField's changeListener, you can reference the field and use setValue() to update it.
I see you have a separate similar question, now solved:
Issue while using moving effect on slider

Update a text field in BB OS 6 when a listener method is invoked

For the GUI portion of my app, how could I update the RichTextField when my batteryStatusChange method is invoked that changes on the spot?
I was thinking of calling a set method and then having RichTextField get that new number, but it will make a long list of lines unless I delete the textfield before I add a new one.
Something like the battery percentage number under Device Information or the signal strength that changes on the spot.
Edit: Figured it out using setText
public void batteryStatusChange(int status)
{
// TODO Auto-generated method stub
if ((status & DeviceInfo.BSTAT_LEVEL_CHANGED) != 0)
{
batteryStatusField.setText(getBatteryLevel());
}
}
batteryStatusField.setText(getBatteryLevel());
public String getBatteryLevel() {
return Integer.toString(DeviceInfo.getBatteryLevel()) + " %";
}
Got it to work with this code above by putting it inside my batteryStatusChange listener function. Later I will add in more parameters after the function getBatteryLevel() to keep my default formatting.
My battery app in progress

Accessing Comment Changes in a Spreadsheetgear WorkbookView Control

I have a C# application that uses SpreadsheetGear's WorkbookView control. A user wants to be able to have changes he makes to comments on a cell saved.
Does anyone know of a way to capture changes when a user edits a comment. The cell edit events are not fired when a comment is edited and I can not find any way to capture changes a user makes to comments.
Before I read Joe's reply not knowing of a way to save comments individually, I decided to save comments by looping through the cells in a workbookView and grabbing the comments as the form is closing.
After seeing his reply, I found a way to get a comment right after it is entered using a combination of the workbookView1_ShapeSelectionChanged and workbookView1_ShapeAction events. The workbookView1_ShapeSelectionChanged event fires when the comment box is opened for editing and when the comment box is closed for editing. When it fires for the comment box opening, I get the ActiveCell because it may no longer be the ActiveCell when the comment box closes. I use that cell for getting the comment when the comment box closes if a comment has changed. The workbookView1_ShapeAction event fires everytime a new character is entered in the comment box which is useful for marking the comment as changed. After the comment is saved, the commentChanged variable is set back to false. Here is the code using the code that Joe posted in his answer:
private void workbookView1_ShapeAction(object sender, SpreadsheetGear.Windows.Forms.ShapeActionEventArgs e)
{
switch (e.ShapeActionType)
{
case SpreadsheetGear.Windows.Forms.ShapeActionType.TextChanged:
if (e.Shape.Type == SpreadsheetGear.Shapes.ShapeType.Comment)
{
//set comment changed flag to true
_commentChanged = true;
}
break;
}
}
private void workbookView1_ShapeSelectionChanged(object sender, SpreadsheetGear.Windows.Forms.ShapeSelectionChangedEventArgs e)
{
if (_commentChanged)
{
//get comment
string comment = _commentCell.Comment.Shape.TextFrame.Characters.Text;
//save comment
//....
//set comment changed flag to false
_commentChanged = false;
}
else
{
//get the cell whose comment is being edited
_commentCell = workbookView1.ActiveCell;
}
}
Unfortunately, the answer is "sort of but not really".
You can catch the ShapeAction event as demonstrated below, but the ShapeAction event is really designed for shapes and not for comments so you cannot get the current text (the text hsa not yet been stored in the shape) and you cannot even get the cell which the comment belongs to. Still, I will paste in some code since it might be of use to you:
private void workbookView1_ShapeAction(object sender, SpreadsheetGear.Windows.Forms.ShapeActionEventArgs e)
{
switch (e.ShapeActionType)
{
case SpreadsheetGear.Windows.Forms.ShapeActionType.TextChanged:
if (e.Shape.Type == SpreadsheetGear.Shapes.ShapeType.Comment)
{
// Unfortunately, this is as far as we can get since IShape
// does not have a way to get back to the cell which owns the comment.
//
// Furthermore, the text is not yet stored in the IShape, so we
// cannot get the current text either.
}
break;
}
}
If you send email to support at SpreadsheetGear requesting this capability they will add this feature request to their list with your email address associated with it.

Resources