Write into 2 TextBox with a ":" between? [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have a setting in C# like this:
3:20
And I want to transform this setting to 2 TextBox like:
3 (TextBox1)
20 (TextBox2)
I have a problem with the ":"

Using String.Split, this will break the string into an array of strings containing two strings, 3 & 20, then set the text box text accordingly.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string setting = "3:20";
string[] settingsArray = setting.Split(':');
textBox1.Text = settingsArray[0];
textBox2.Text = settingsArray[1];
}
}

Related

Why cant I get my text file to sort itself [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 days ago.
Improve this question
C#, I need to have my code read a file, then sort it alphabetically, so far I can select and read the file, and also make everything lowercase, but I need it to be sorted and im not sure how.
I am expecting alphabetically sorted list from the text file
code:
private void button1_Click(object sender, EventArgs e)
{
if (openFile.ShowDialog() == DialogResult.OK)
{
string readFile;
StreamReader inputFile;
inputFile = File.OpenText(openFile.FileName);
readFile = inputFile.ReadToEnd().ToLower();
fileTextBox.Text = readFile;
}
else
{
MessageBox.Show("Cancelled");
}
}

Calculate average when checkbox are checked C# [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Good morning everyone!
So, I have 8 textboxes and under those are checkboxes. To those textboxes I'am always receiving data from a serialport and I need to do an average from those values. But I only want to do the average from the textboxes from which I checked the checkbox under them.
How can I add those values to the average formula when selected by checking the checkbox?
If anyone could help, I would really apreciate.
Thanks,
Jonathan
I think you should write something like this :
bool[] CheckBoxList { get; set; } = new bool[8];
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
CheckBoxList[0] = checkBox1.Checked;
CalcAverage();
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
CheckBoxList[1] = checkBox2.Checked;
CalcAverage();
}
in CalcAverage method , Textboxes with a true value in the list are computed.

C# - How can programm a textbox that add tags into a listbox just like stackoverflow tags are coded? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
Everytime I click enter, he deletes the textbox, adds the text of the word into the listbox?
Basically, the code-behind of an Windows Forms App that does what you asked in a REALLY BASIC way, would be the following:
using System.Windows.Forms;
namespace WindowsFormsApp1 {
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if(e.KeyChar == 13) //checks if "enter" was pressed
{
listBox1.Items.Add(textBox1.Text);//adds the text to the list
textBox1.Clear(); //clear the text of the textbox
}
}
} }

How to remove contextmenu items from gecko webbrowser control,"i want to disable view source in browser" [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
private void geckoWebBrowser1_ShowContextMenu(object sender, GeckoContextMenuEventArgs e)
{
if (e.ContextMenu.GetContextMenu().MenuItems.RemoveAt("view in system )
{
}
}
private void geckoWebBrowser1_ShowContextMenu(object sender, GeckoContextMenuEventArgs e)
{
foreach(MenuItem i in e.ContextMenu.MenuItems)
{
if(i.Text == "View in System Browser")
e.ContextMenu.MenuItems.Remove(i);
}
}

setting up the timedate string so that it can be manipulated on a different webform? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
public partial class WebForm1 : System.Web.UI.Page
{
string timedate = DateTime.Now.ToString("MM/dd/yyyy HH:mm:tt");
protected void Page_Load(object sender, EventArgs e)
{
}
If I understood you correctly and you need to share data between 2 pages (webforms) you can use Session:
e.g. on one page:
string timedate = DateTime.Now.ToString("MM/dd/yyyy HH:mm:tt");
Session["timedate"] = timedate;
on another page:
string timedate;
if (Session["timedate"] != null) {
timedate = Session["timedate"].ToString();
}

Categories

Resources