I'm working on a project now, to make it easier to work I decided to make related textbox, the question is how to set the value of textbox so that it will be appears automatically?
Inthis case, Rnol = Pnol + Qnol + Nnol
I want Rnol value to be printed automatically in tbRnol/textbox Rnol when I click Button..
Pnol = double.Parse(tbPnol.Text);
Qnol = double.Parse(tbQnol.Text);
Nnol = double.Parse(tbNnol.Text);
Rnol = Pnol + Qnol + Nnol(tbRnol.Text); //I've try this but it clearly wrong syntax
You could modify your last line to:
Rnol = Pnol + Qnol + Nnol;
And add this one:
tbRnol.Text = Rnol.ToString();
Related
We're trying to populate a Calendar for our Installation Team that shows distinct values from a query of Van Number and Install Time on each date in the calendar. We have it so there's a clickable Date in each cell that does something, and below that a Text String shows up with the Van # and Time. However this is duplicating.
We thought it was the String, but if we make build the same string and write it to the ToolTip for that Cell, it displays correctly. So it's that cell text for some reason.
Here's the relevant code:
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
String Install = "";
String ToolTip = "";
Literal insta = new Literal();
Literal lit = new Literal();
e.Cell.BackColor = System.Drawing.Color.SkyBlue;
var rows = (from row in socialEvents.AsEnumerable()
where DateTime.Parse(row["InstallDate"].ToString()) >= e.Day.Date &&
DateTime.Parse(row["InstallDate"].ToString()) < e.Day.Date.AddDays(1)
select new
{
VanNum = row["VanNum"],
InstallTime = row["InstallTime"]
}).Distinct();
foreach (var row in rows)
{
String MyInstall = "";
MyInstall = "Van #: " + row.VanNum.ToString() + " / Install Time: " + row.InstallTime.ToString();
Install = Install + "<br/>" + MyInstall;
ToolTip = ToolTip + "/n" + MyInstall;
}
e.Cell.ToolTip = ToolTip;
lit.Visible = true;
e.Cell.Controls.Add(lit);
insta.Text = Install;
insta.Visible = true;
e.Cell.Controls.Add(insta);
}
e.Cell.ToolTip will display 3 rows, but the Literal insta.Text in the Cell Control will show it twice. The Literal lit seems to be adding the clickable Date (which I admit, I don't know how its doing that) which is why there's two Literal Controls. If we just write a single Literal Control then we lose the clickable Date but the Install data is still duplicated.
After testing more we found that the Control with text was being added twice. Not sure why we didn't see the date twice as well. But we found the answer here:
https://forums.asp.net/t/453021.aspx?My+DayRender+event+is+happening+twice+and+I+don+t+know+why+
The DayRender event was firing twice, so removing
OnDayRender="Calendar1_DayRender"
from the ascx page removed the redundant firing and text only displayed once. I'm still unsure why the Date gets added to lit and only once, but that seems to be generated elsewhere and probably accounted for. This also explains the ToolTip working, because its getting set where the Control is being added.
i have a Trackbar and want it to add the Current Value to a richtextbox Text without replacing the whole Text Line
richTextBox1.Rtf = richTextBox1.Rtf.Replace("aimbot_aimtime=85.000000", "aimbot_aimtime=" + trackbarpercent.Text + ".000000");
(i get the Value from my Label)
Thats what im using right now but it only Replaces it if the Text is "aimbot_aimtime=85.000000"
i want it to add the new Value after "aimbot_aimtime=NEWVALUE" but i cant get it to work atm
#Marc Lyon
I think a better way for me is to Replace the Line itself cause its always Line 7
Got it working, thanks to all who helped :)
void changeLine(RichTextBox RTB, int line, string text)
{
int s1 = RTB.GetFirstCharIndexFromLine(line);
int s2 = line < RTB.Lines.Count() - 1 ?
RTB.GetFirstCharIndexFromLine(line + 1) - 1 :
RTB.Text.Length;
RTB.Select(s1, s2 - s1);
RTB.SelectedText = text;
}
private void trackbarpercent_Click(object sender, EventArgs e)
{
changeLine(richTextBox1, 7, "aimbot_aimtime=" + aimtimetrackbar.Value + ".000000");
}
You have to know what the value is in order to replace it, which is why it only works when the value is your default value of 85.
In order to replace the text with the new text, you will have to track the previous value somewhere to use in your replacement. This means a field in your form, a property in some class. Let's say you create an int field on your form (myForm) called oldAimbot_aimtime. Every time the slider changes, put old value into this field. now your code becomes:
var prompt = "aimbot_aimtime=";
var oldvalue = string.Format("{0}{1}", prompt, myForm.oldAimbot_aimtime);
var newvalue = string.Format("{0}{1}", prompt, {NEWVALUE}.Format("#.######");
richTextBox1.Rtf = richTextBox1.Rtf.Replace(oldvalue, newvalue);
This code is off the top of my head and may not work exact, but it should replace the value. What is the value of using a richtextbox on a config screen? Can you post a screenshot?
OK, I see the screenshot. Ethics aside (not sure there is such a thing as a legit aimbot). You are using the richtextbox presumably because it was the easiest control for you to style...
Where you use the richtextbox is probably better suited to a GridView, ListBox, maybe even a treeview where you have finer control over each element.
If you want to use the richtext, write code which emits each option, then you can obtain exact values to use in rtf.Replace()commands
Hope this helps.
I'm trying to replace a certain line in a .txt file when I click the Update Button
This is what my program looks like
http://i.imgur.com/HKu4bGo.png
This is my code so far
string[] arrLine = File.ReadAllLines("Z:/Daniel/SortedAccounts.txt");
arrLine[accountComboBox.SelectedIndex] = "#1#" + firstNameInfoBox.Text + "#2#" + lastNameInfoBox.Text + "#3#" + emailInfoBox.Text + "#4#" + phoneNumberInfoBox.Text + "#5#EMAIL#6#";
File.WriteAllLines("Z:/Daniel/SortedAccounts.txt", arrLine);
This is what's inside SortedAccounts.txt
#1#Bob#2#Smith#3#Bob#Smith.com#4#5551234567#5#EMAIL#6#
#1#Dan#2#Lastyy#3#Daniel#Lastyy.com#4#5551234567#5#EMAIL#6#
The ComboBox is in the order as the Txt File.
So I get the same Index as the selected item in the ComboBox. And then I want to delete that line and then add a new line that same txt file with the updated information.
My code isn't doing this for some reason though and I can't figure it out
Try this out using List to easily remove an entry at a certain index. Don't forget to reload the combobox data source when the file is updated to avoid index mismatch etc..
List<string> arrLine = File.ReadAllLines("Z:/Daniel/SortedAccounts.txt").ToList();
arrLine.RemoveAt(accountComboBox.SelectedIndex);
string newLine = "#1#" + firstNameInfoBox.Text + "#2#" + lastNameInfoBox.Text + "#3#" + emailInfoBox.Text + "#4#" + phoneNumberInfoBox.Text + "#5#EMAIL#6#";
arrLine.Add(newLine);
File.WriteAllLines("Z:/Daniel/SortedAccounts.txt", arrLine);
well, I've been trying to create a new custom property in a shape and I somehow managed, however, when I try to change the name of the Label I can only write numbers. Could you provide me how to do it in C# or maybe in VB so I can get a hint?
My code is:
//First I create the row
shape.AddRow((short)VisSectionIndices.visSectionProp,(short) (iRow + 1), (short) VisRowTags.visTagDefault);
//And now I try to write the Label
shape.CellsSRC[(short)VisSectionIndices.visSectionProp, (short)(iRow + 1), (short)VisCellIndices.visCustPropsLabel].Result[VisUnitCodes.visNoCast] = 123456789
However, when the Result method only accepts boolean as input, and I don't know how to write a string overthere...
Thanks in advance!
I've also been looking into how to set the string value of a custom shape data property.
Just got it to work like this:
var newPropertyValue = "cool new value";
tstShape.Cells["Prop.SuperCustomPropertyName"].FormulaU = "\"" + newPropertyValue + "\"";
Disclaimer that I am no expert with Visio Automation, but it works in my circumstance.
I'm using visio 2010 and studio 2010
Hopefully it helps.
You can use the following code:
private void AddCustomProperty(Microsoft.Office.Interop.Visio.Shape shape, string PropertyName, String propertyValue)
{
try
{
short customProps = (short)VisSectionIndices.visSectionProp;
short rowNumber = shape.AddRow(customProps, (short)VisRowIndices.visRowLast, (short)VisRowTags.visTagDefault);
shape.CellsSRC[customProps, rowNumber, (short)VisCellIndices.visCustPropsLabel].FormulaU = "\"" + PropertyName + "\"";
shape.CellsSRC[customProps, rowNumber, (short)VisCellIndices.visCustPropsValue].FormulaU = "\"" + propertyValue + "\"";
}
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show("Error: " + e.Message);
}
}
The Result isn't meant to be read/write. What you want to do is set the FormulaU property of the cell to the label name. The Result property just calculates the formula for the cell and returns the result, which is why you have to provide a unit for the return value.
Also, the AddRow method returns the actual row number for the added row, which isn't necessarily the row you specified. For shapesheet sections with nameable rows, like the Custom Properties section, Visio may ignore the row you requested and just stick it at the bottom.
So I want to have a number that can be added to but then written out in a label. I'm doing it in Visual C#.NET.
For example, if I had code like this (either in a timer or while loop):
int i = 0;
i = i + 5;
label4 = "Current Number of Views: " + i.ToString();
I can't use ToString() to convert it to a string. So how would I make i displayable
While I don't understand why you can't use i.toString(), I suppose that you could also use something like
label4.Text = String.Format("Current Number of Views: {0:d}", i);
This should yield the same result.
Edit: as #BiggsTRC points out (which I didn't think of), your error is probably a result of not assigning to the right variable. You probably should access the property label4.Text to assign to. The code example fixes this properly now.
u could use String.Format without explicitly using ToString()
label4.Text = String.Format("Current Number of Views: {0}", i);
This should work. The one issue i see is the label itself. It should look like this:
label4.Text = "Current Number of Views: " + i.ToString();
I dont understand why cant you use i.ToString(). By default, i is assigned with 0 value and hence, i.ToString() would not throw any exception.
if you are using WPF , then you should assign the value to the content property of the label.
label4.Content = "Current Number of Views: " + i.ToString();