|
Hi,
I don't know, however this page[^] would make me try BaseFont.CP1254 instead of "iso-8859-9"
|
|
|
|
|
I want to open with a click on a button, some sort of dialog which contains text in a new window.
The problem is that i want to have both forms active, so the user can click on both. Or at least have the dialog form locked but you can still close it, and original form opened.
I have already created a pop up form but when it pops up, you cant use the original form.
Any suggestions?
|
|
|
|
|
Both usable at once:
MyOtherForm mof = new MyOtherForm();
mof.Show(); Close and continue:
MyOtherForm mof = new MyOtherForm();
if (mof.ShowDialog() == DialogResult.OK)
{
...
}
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Awesome, thanks it works. I have used ShowDialog instead of just Show. Thats way first form was locked.
|
|
|
|
|
You're welcome!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
When you set the 'Owner property of a Form to another Form, then you guarantee that when you 'Show the owned Form, it will be visible in front of (higher in the z-order) the owner Form: [^]
Both Forms will be movable, visible, usable.
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
Hi all,
I'm EXTREMELY new to c# visual studios and honestly don't understand it at all but have to do a piece of coursework.
I have to create a controller for a washing machine and on the user interface I'd like to have a button labelled 'temperature' that when clicked will scroll through multiple options, like on a real washing machine.
So I've inserted a button and I have a checkedlistbox with all of the available temperatures but really don't know where to go from there.
Is there any way I can have the button click once to select 30C, then when clicked again selects 40C and when clicked again selects 60C (then any clicks after that just repeat the cycle)??
I'd really like to learn how to do this please!
|
|
|
|
|
You're going to need to start by telling us what UI framework you're using. Is it Windows Forms? WPF? ASP.NET WebForms? ASP.NET MVC? ASP.NET Core? Something else?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Although knowing what environment you are working in would certainly help, the principle is the same in all environment, just the details will change.
The way I'd do it* is to create an array of strings:
private string[] Temperatures = { "30C", "40C", "60C", "90C" }; And a current setting variable:
private int currentTemp = 0; Then each time the button was clicked I'd change it:
private void butTemp_Click(object sender, EventArgs e)
{
currentTemp++;
if (currentTemp >= Temperatures.Length)
{
currentTemp = 0;
}
butTemp.Text = Temperatures[currentTemp];
}
* Well, not really, I'd use a "TemperatureSetting" class instead of strings and temps to hold it all together - but that's the more advanced stuff.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
That would result in an awkward UI: whenever I want anything but 30C, I would need to click the 30C button
I'd rather have a label showing the current temperature setting, and the button saying "Change temperature".
How about a bunch of RadioButtons inside a GroupBox? or a user-defined scrollbar? or ...
|
|
|
|
|
I'd agree, but then, I don't design washing machines ... if I did, they'd not grow mould, would show you how long they had before they were finished, could be told to run on cheap rate electricity, and be a damn sight quieter.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Can I pre-order one?
|
|
|
|
|
I'll put you at the top of the list if I ever go into the industry!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
"have to do a piece of coursework."
If your class/teacher has not equipped you, so far, to start writing code, then something is wrong here.
Is everyone else in the class confused ? If that's true, then something may be wrong with the teacher, or the course content. If the other students are not having difficultly, perhaps ask your teacher's help to figure out why you are having difficulty.
If we write code for you, you wiil learn nothing.
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
There are many ways that you could do this. A simple way to do this would be to simulate a circular Linked List with the last entry pointing back to the first entry. That way, you would only have to walk through the list.
This space for rent
|
|
|
|
|
Hello,,i wrote a code for finding the nth term in the series an print the result. So, I used a while loop in that,where I used 2 variables named tem1,tem2. When I print after the while loop,it is snot printing the updated value.Can anyone suggest a solution.
public class ArmstrongExample
{
public static void Main(string[] args)
{
int ip1, ip2, ip3, ip4, res, tem2 = 0;
ip1 = Int32.Parse(Console.ReadLine());
ip2 = Int32.Parse(Console.ReadLine());
ip3 = Int32.Parse(Console.ReadLine());
ip4 = Int32.Parse(Console.ReadLine());
res = summeet(ip1, ip2, ip3, ip4);
Console.WriteLine(res);
int summeet(int p1, int p2, int p3, int p4)
{
int a, b, c, n, tem1, i = 0, d1, d2;
a = p1;
b = p2;
c = p3;
n = p4;
while(i>n-3)
{
d1 = b - a;
tem1 = d1 + c;
d2 = c - b;
tem2 = tem1 + d2;
i++;
tem1 = tem2;
}
return tem2;
}
}
}
|
|
|
|
|
That won't compile. Why not? You don't declare tem2, and if you do, you need to give it a default value or you can't return it.
In addition there is no good reason for a local function here: it just makes the code harder to read.
If it doesn't compile, it doesn;t generate an executable file, so the version you run is the last "compile error free" version of your source code.
Fix the compilation errors, and it may work better:
public static void Main(string[] args)
{
int ip1, ip2, ip3, ip4, res, tem2 = 0;
ip1 = Int32.Parse(Console.ReadLine());
ip2 = Int32.Parse(Console.ReadLine());
ip3 = Int32.Parse(Console.ReadLine());
ip4 = Int32.Parse(Console.ReadLine());
res = summeet(ip1, ip2, ip3, ip4);
Console.WriteLine(res);
}
private static int summeet(int p1, int p2, int p3, int p4)
{
int a, b, c, n, tem1, tem2 = 0, i = 0, d1, d2;
a = p1;
b = p2;
c = p3;
n = p4;
while (i > n - 3)
{
d1 = b - a;
tem1 = d1 + c;
d2 = c - b;
tem2 = tem1 + d2;
i++;
tem1 = tem2;
}
return tem2;
}
But do yourself a favour: stop using as-short-as-possible names for things: it may seem like a waste of time and more work, but using descriptive names makes your code document itself, and that means it's more readable. It also means it's a lot easier to tell when you used the wrong variable, and that makes your code more reliable and easier to debug. the variables a, b, c, and n are unnecessary, you can use the parameters directly instead; and give them sensible names instead of "p1", "p2" and so on. That way, when you want to use the method later, Visual Studio will even prompt you as to what value belongs in what parameter!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
You really need to learn how to use a debugger. If you had used one (as well as given us the code where tem2 was declared), you would see that your while condition would never finish. So, why won't it finish? Well, you have declared a variable called n which gets a default value of 0; you haven't actually allocated anything to it. Now, when your program runs, you will see that i (which starts at 0) will always be greater than n-3, so it never terminates. Honestly, you could have found this out in a minute with the debugger.
This space for rent
|
|
|
|
|
Hi,
I fail to see what your loop is trying to achieve; the variable i will be incremented on each iteration, however the five other variables will never change once the first iteration has finished...
Furthermore, when the loop tests for larger than, I expect the control variable to be lowered inside the loop, and not incremented. Otherwise you may end up waiting for an “integer overflow”.
modified 10-May-18 5:09am.
|
|
|
|
|
private void stsearch_Click(object sender, EventArgs e)
{
string stringToSearch = (@"D:\\st.txt" + stname.Text);
string[] lines = File.ReadAllLines(@"D:\\st.txt");
var lineCount = File.ReadLines(@"D:\\st.txt").Count();
foreach (string line in lines)
{
if (line.Contains(stringToSearch))
{
if (str1 != null)
{
lines = str1.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
}
for (int i = 0; i < lineCount-1; i++)
{
subarray = lines[i].Split(',');
stage.Text=subarray[1].ToString();
stgender.Text= subarray[2].ToString();
}
}
}
|
|
|
|
|
I don't think you can, if I read what you are trying right.
You seem to be looping round for each line in the file, splitting it on commas, and trying to display each line in a textbox: but that won't work, because each time you assign a new value to the Text property, it throws away what was in the textbox before:
stage.Text=subarray[1].ToString();
stgender.Text= subarray[2].ToString(); YOu could use a multiline textbox, and append each result to a new line, but that's a bit of a cack-handed approach. Have you considered using a DataGridView instead?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Mohamed Fahad M wrote: string[] lines = File.ReadAllLines(@"D:\\st.txt");
var lineCount = File.ReadLines(@"D:\\st.txt").Count();
That would read the file twice, once just to get the count.
var lineCount = lines.Count(); Learn to walk before trying to run.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Nah. I still prefer old school stuff such as
int lineCount=lines.Length;
|
|
|
|
|
You're right, of course
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
repost of: [^]
Please do not repost: as you make progress, edit your original post.
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|