Alright, I thought this would be simple, but apparently I don't know what I am doing. I have a Rich Text Box that populates upon form load. There are fields that are meant to be updated by text boxes on this form. Here's a snip of the form_load:
So what happens here is the form opens and populates a rich text box with:
CIF = N
Now, what I need to have a button do is update just the items I have defined, in this case chkCIF (a check box) and timeCIF.Text (a textbox). I have a button that's called update, and here's what it looks like.
privatevoid updateButton_Click(object sender, EventArgs e)
//There is a combo box on this form and example is the first optionif (comboInst.Text == "Example")
//Here is where the check box verification is, if it is true it should change the N to Yif (checkCIF.Checked == true)
//This part needs to update the current contents of the email body. Obviously, this isn't working for me so I commented out some examples I tried...//string s = emailBody.Text;//string chkCIF = "Y";//s = s.Replace("N", chkCIF);string theString = emailBody.Text;
theString.Remove(3, 2).Insert(3, "Y");
And there you have it. I just need to be able to update certain defined words from a string with a click of a button. Thanks in advance
Okay.... you are replacing/removing the text but then throwing the result away. You need to set your emailBody.Text back to the string that you have updated.
emailBody.Text = theString.Remove(3, 2).Insert(3, "Y");
I don't know too much about it but I do not believe that the stock rich text box supports the concepts of rows.... A cheap easy way to do what you want would be to split your string (Split function) replace the text in the resulting array and then rejoining the array back into a string. Easier than is sounds.
I understand what you're saying there and if a rich text box isn't the best way I think I can work backwards on what I want to do then.
How about writing the information to a text file, then calling it to the text box once it's updated in the text file?
Here is the "flow" of things:
Form loads and a .txt file is generated as a template.
User checks the box which makes the N turn into a Y in the text file.
User inputs the time into a text box.
User clicks the "Update Form" button which saves the text document and then pulls the entire document into the rich text box revealing the changes.
Does that sound like a better option? This just creates a new situation I have yet to attempt, but is on my "to learn" list, writing information to a specified position in a text file/reading from a text file.
Why not keep all the individual pieces of text as separate variables and then rebuild the RichTextBox[^] using its methods, whenever an item changes? This should make it much easier to add or remove specific items in the future.
i want to display a graph,i related it to my database "powerdb" it has a table called powertable with 2 attributes: "power" and "time",but when i run it,nothing appeares. only a white window.
publicpartialclass Form1 : Form
powerdbDataSet db = new powerdbDataSet();
privatevoid Form1_Load(object sender, EventArgs e)
// TODO: This line of code loads data into the 'powerdbDataSet.powertable' table. You can move, or remove it, as needed.this.powertableTableAdapter.Fill(this.powerdbDataSet.powertable);
chart1.Series.XValueMember = "time";
powertableBindingSource.DataSource = db.powertable;
privatevoid chart1_Click(object sender, EventArgs e)
Hey guys, I am trying to create a matrix which allows a user to either turn a square on or off by clicking it. It needs to be 6X8 squares. So far all I can think of is creating 48 buttons, or maybe even a panel split into 48 sections? I am looking for a solution that is not too complex, so any advice on how to do start this would be much appreciated!
Override panel and override the mouse click and mouse move event and OnPaint event. An array of buttons is simpler but you will be happier with results the other way. Neither Windows Forms nor WPF likes a lot of controls and the correct answer a lot of times is custom controls. With such a simple case you will have the opportunity to learn a valuable tool to put in your toolbox.
I have created a program which extracts metadata out of a PST. This data has then been stored in a text file.
I am trying to create a set of charts/graphs which will represent the data which I have pulled out. Is it possible using Visual Studio 2010 to create a bar chart for example using variables or by reading specific data which I have written to the text file.
I know that VS 2010 does have the inbuilt chart feature; however, I can't seem to get it to work off values held in a variable (only from databases, a service, an object or SharePoint).
I am new to programming in C# and using Visual Studio so I may be missing something very simple! I have googled for days and have had no light.