I have a visio shape with shape data column Prop.Name of type string
when i try to set its value using
Visio.Cell propCell = _shapeList[i].get_Cells("Prop.Owner");
propCell.FormulaForceU = "asd";
I get an error: #NAME?
This does not happen if i pass a numeric string .
How can i pass characters other than number ?
propCell.FormulaForceU = "\"asd\"";
I am trying to update the shape property value with the normal string as like 'Set Value' it gives error #NAME?.
After giving
c.Formula ="\"Set Value\"";
it begins to work.
Related
I use Controls.Find to get the value of a textbox which I don't know the name of until runtime. However the result returned by Controls.Find cannot seem to be converted into a string OR an integer (ERROR MSG:
CS1503 Argument 1: cannot convert from 'System.Windows.Forms.Control' to 'string'). I thought that if I could convert it to string first then it wouldnt be a problem converting to integer but it wont even let me convert it to string. Most mysteriously though, it prints this value to screen when I use Console.WriteLine(tbValue)! Can anyone help?
//This function takes the name of a textbox from an array and returns the value of it
int GetDynamicTextboxValue(String tbName)
{
int value = 0;
var matches = this.Controls.Find(tbName, true); //although matches is an array we are only expecting one result
foreach (var tbValue in matches)
{
Console.WriteLine("Dynamic textbox value = " + tbValue);
value = Int32.Parse(tbValue);//This is where the conversion error occurs
}
return value;
}
You actually have Controls collection at the moment which is the base class and of all the controls like TextBox, Label.
You will need to connvert the Control object to TextBox and then get the value from Text property of TextBox class something like:
foreach (var tbValue in matches)
{
Console.WriteLine("Dynamic textbox value = " + tbValue);
// cast the control as TextBox object
var textBox = tbValue as TextBox;
// if casting successful textBox will have reference to that textBox
if(textBox !=null)
value = Int32.Parse(textBox.Text);// now get the value of textbox and convert to integer
}
I dont get it please help me in line of lblGrandTotal = ""; it said
Cannot Implicitly convert type 'string ' to System.Window.Forms.Label
It should be as below :
lblGrandTotal.Text = "";
You should set the .Text property of the control lblGrandTotal:
lblGrandTotal.Text = "";
use lblGrandTotal.Text = "yourText";
You are trying to assign text to a Label object type.
You need to set the Text property. Furthermore, it's better code if you do lblGrandTotal.Text = string.Empty rather than "". Nit picking, but better code.
int AccNo = Convert.ToInt32(AccMaskedTextBox.Text);
This is how I try to assign the input of my maskedtextbox. The issue I have is that I set a custom mask. It is in the form of 000-000. When I try to assign the input of maskedtextbox to AccNo it breaks with the error :
Input string was not in a correct format.
The value of AccNo comes out to be for example 123-456 if string type is used. So I need to get rid of the hyphen so I can assign it to type int.
How can I do t without changing my mask?
The easiest would be using Replace to replace the hyphen with nothing:
int AccNo = Convert.ToInt32(AccMaskedTextBox.Text).Replace("-", string.Empty);
Here is my code within my ASP.net project. I am trying to store some values into my object with my web form, but it pops up an error message saying: Cannot implicitly convert type 'short' to 'string'.
textbox.Text = Convert.ToInt16(object.number);
lstbox.SelectedValue = Convert.ToInt16(object.ID);
Within my object class, I have declared my variables to int. Please let me know what is wrong.
The Text and SelectedValue properties are strings. Why would you convert the values to short in the first place?
textbox.Text = object.number.ToString();
lstbox.SelectedValue = object.ID.ToString();
You can't assign non-string values to a property which accepts string/text values. In your case, you are trying to assign a short value to text property of textbox. Please cast the value to string using Convert.ToString or ToString().
So your code should be
textbox.Text = Convert.ToString(object.number);
or
textbox.Text = object.number.ToString();
Scenario is same while assigning the selected value property of listbox.
lstbox.SelectedValue = Convert.ToString(object.ID);
Since you want to pass the value to the object, you should have the object's variables = the input value.
object.number = Convert.ToInt16(textbox.Text);
object.ID = Convert.ToInt16(lstbox.SelectedValue);
Im currently making usercontrol for umbraco that takes all Nodes indside a Node names "Features"...
And it all works perfekt, until i wanted to get content from the "Content Picker" property (named linkToPage).
When i tried to use GetProperty("linkToPage").Value, I got an error about it being an object.
So i then added it to a var and debugged, and saw it returned somthing a bit strange...
var linkIdVar = child.GetProperty("linkToPage");
Returns:
- linkIdVar {1081} umbraco.interfaces.IProperty {umbraco.NodeFactory.Property}
- [umbraco.NodeFactory.Property] {1081} umbraco.NodeFactory.Property
Alias "linkToPage" string
Value "1081" string
+ Version {00000000-0000-0000-0000-000000000000} System.Guid
+ Non-Public members
Alias "linkToPage" string
Value "1081" string
+ Version {00000000-0000-0000-0000-000000000000} System.Guid
And i can't seem to get the Value to a Int without getting error about it being an object...
So does anyone know how to get arround this, or know a better way to get the page from a Content Picker?
I think you might need to unbox the value to an integer, like so:
var val = (int) child.GetProperty("linkToPage").Value;
However, if the content of the property value is not an integer, but a string, as the debugging information seems to indicate, then you need to convert to an integer, like so:
var val = int.Parse(child.GetProperty("linkToPage").Value as string);