1,469 Posted Topics
Re: Check out this code: [CODE] public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); open.Filter = "Image Files(*.png; *.jpg; *.bmp)|*.png; *.jpg; *.bmp"; // Allow the user to select multiple images. open.Multiselect = true; open.Title = … | |
Re: ddanbe: my car has some problems too. But I am really not sure what to do now... PS: I will stop answering on these kind of not-even-half-explined-threads. | |
Re: This is not a good way to close the form. You better do a loop of all forms, and then check which you want to select. Selected put into an array (pre-created), and when the code goes throught the loop (when it ends), go through the array of forms, and … | |
Re: Try it this way: [CODE] private void button1_Click(object sender, EventArgs e) { Label l = new Label(); l.Location = new Point(100, 100); l.Text = "This is a text"; this.Controls.Add(l); } [/CODE] | |
Re: Here is some simple example how to use form and class: [CODE] public partial class Form1 : Form { public Form1() { InitializeComponent(); string value = "ABC"; NewClass nc = new NewClass(value); nc.MyMethod(); } } public class NewClass { string classVariable; public NewClass(string parameter) { //constructor! string methodVariable = parameter; … | |
Re: Check this out: [CODE] string value = "212132134214"; char[] array = value.ToCharArray(); StringBuilder sb = new StringBuilder(); foreach (char str in array) sb.AppendLine(str.ToString()); MessageBox.Show(sb.ToString()); [/CODE] | |
Re: This how: [CODE] string a = "1 2 : 3"; string b = a.Replace(":", ""); //removes : string[] split = b.Split(' '); //splits to 3 characters [/CODE] Mitja | |
Re: Check this example: [CODE] string[] array1 = { "12345", "145", "1345" }; string second= "23"; int sum = 0; foreach (string item in array1) { if (item.Contains(second)) sum++; } MessageBox.Show("There is/are " + sum + " strings of \"" + second + "\" string in the array."); [/CODE] | |
Re: What you have to do is to select that quantity field and subtract 5. When you will select the value, you then have to do an update over that field with the new value (Field = Field -5). | |
Re: Check this example: [CODE] ArrayList aList = new ArrayList(); aList.Add("1 2"); aList.Add("2 1"); aList.Add("2 3 1"); aList.Add("2 4 1 3"); ArrayList aListNew = new ArrayList(); //you have to create a new array list, because you cannot modify the list in the loop! foreach(string item in aList) { //creating a int … | |
Re: You some boolan flag. Like this: [CODE] bool bChecking; void textBox1_Leave() { if (!bChecking) { //put your code in the event in here! } } void YourCurrentMethod() { //do some code, which you want to do, and which fires Leave event of textBox! //just before the code fires the Leave … | |
Re: No, only the method you declate in the new thread creation. | |
Re: [QUOTE=apanimesh061;1522790][CODE] using system; public class Hello{ public static void main(){ console.WriteLine("Hello C# World :)"); } } [/CODE] [/QUOTE] Maybe the problem lies in the "console" keyword (Console class) because it is written wth small initial. You have to write it with a big initial, like "Console". This works: [CODE] using … | |
![]() | Re: Simple: Constructor is only a method, which has this previlege that is called first when a new instance of a class (or form) is created. It is called automatically when this instance gets created. ![]() |
Re: or: [CODE] double min = sortList.Min(x => x.Value); [/CODE] | |
Re: You dont need any constructor. At least if you open form2 from from1 (or form3 from form1). | |
Re: [CODE]comboBox1.Text //an example code: comboBox1.Items.AddRange(new string[] { "item 1", "item 2", "item 3" }); comboBox1.Text = "Select date"; [/CODE] property will do it ones again! But I would like to ask you how do you populate data into comboBox? | |
Re: do: [CODE] //in button click event: listBox1.Item.Add(textBox1.Text); [/CODE] and for setting the text to other controls you do: [CODE] private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { radioButton1.Text = listBox1.SelectedItem.ToString(); textBox1.Text = listBox1.SelectedItem.ToString(); //and so on.. } [/CODE] | |
Re: Wi, would you mind showing us the code, so we can see if there is something wrong with it? thx | |
Re: C# Database programming: [url]http://www.amazon.com/Mastering-Database-Programming-Jason-Price/dp/0782141838[/url] | |
Re: Get the states based on selected country to populate comboBox2: [CODE] private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { SqlDataAdapter da1 = new SqlDataAdapter("select State from States where country_name='" + combobox1.SelectedItem.ToString() + "'", "Data Source=.;Initial Catalog=master;Integrated Security=True;"); da1.Fill(ds1); int i = ds1.Tables[1].Rows.Count; for (int s = 0; s < i; s++) … | |
Re: hmmm... Comset2 is what? Where do you inizialize it? What kind of collection is it? | |
Re: Wrong. You have to put a property of a textbox control on the end of it to check it: [CODE] if(textBox.Text != String.Empty) { //not empty (not null, even empty and null are not the same things) } else { //empty! }[/CODE] | |
Re: You didnt even set the min value until here. It is still 0 (or not even that, because you didnt initialize it). So you cannot compare it (if(v > min)! | |
Re: Use have to to sqlExecuteNonQuery() method to exectute an insertion. [CODE] sq1 = "insert into [" + Box1.Text + "] values('" + accid.Text + "', '" + pass.Text + "', '" + sex.Text + "', '" + email.Text + "')"; cmd = new SqlCommand(sq1, cn); cmd.ExecuteNonQuery(); //HERE! [/CODE] | |
Re: use: [CODE] if(this.comboBox1.SelectedIndex > -1) { this.comboBox1.Selecteditem.ToString(); //or: this.comboBox1.Text; //or: this.comboBox1.GetItemText(this.comboBox1.SelectedItem); } [/CODE] one of these it should get the selected item | |
Re: [CODE] if (DialogResult.Yes == MessageBox.Show("Do you want to save into a database?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { //SAVE into database } else { //not saving! then you dont even need this else (you can erase it if you dont need it } [/CODE] | |
Re: YOu forgot to include ' ' to the query around property textbox.Text). Your create query has to look like: [CODE] sq1 = "CREATE TABLE '" + TextBox1.Text + "'(myId INTEGER CONSTRAINT PKeyMyId PRIMARY KEY," +"myName CHAR(50), myAddress CHAR(255), myBalance FLOAT)"; [/CODE] | |
Re: [QUOTE=Kath_Fish;1513709] set of data in text file 1 2 1 3 1 4 [COLOR="red"]2 3[/COLOR] 3 4 Now, i wan to read each item and count the frequency for each item. ITEM FREQUENCY 1 contain 3 2 contain 2 3 contain 3 4 contain 2[/QUOTE] Where did you get this … | |
Re: Would you please stop with the threads names as "Help,,!!". This is getting us no where. And please, stop posting double or even more same posts. All aobut these numbers. Create one thread and hold to it!! I have answered on a couple of your threads, but NONE has been … | |
Re: lol - what a help :) check your pm. | |
Re: [QUOTE=leo88;1518686] The listbox content is as below: {1 2} 4 {1 4} 6 {1 5} 7 {1 3 4} 8[/QUOTE] 1st column is what is in the brackets? And the value out of brackets is your 2nd column, which would be the Value of the dictionary? | |
Re: Where do you initialite a new instance of a class Student? NoWhere. For to do it so, you have to create a local variable of a class: [CODE]Student st1 = new Student(); //s1 is now a reference of a class.[/CODE] for beginining... | |
Re: Check out this code: [CODE] //form1: public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Form2 f2 = new Form2(this); f2.Show(); } public void GetDataFromForm2(List<object> list) { textBox1.Text = list[0].ToString(); textBox2.Text = list[1].ToString(); } } //form2: public partial class Form2 … | |
Re: It has to written like this: [CODE] cmd.CommandText = "select employee_code from MST_Employee where employee_code = '" + emp_code + "';[/CODE] Mitja | |
Re: You ca ndo it this way: [CODE] //form1: public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Form3 f3 = new Form3(); Form2 f2 = new Form2(f3); f2.Show(); } } //form2: public partial class Form2 : Form { Form3 f3; … | |
Re: Try this code: [CODE] int total = 0; foreach (DataGridViewRow row1 in dgv1.Rows) { foreach (DataGridViewRow row2 in dgv2.Rows) { if (row1.Index == row2.Index) { total += (int)row1.Cells[0].Value * (int)row2.Cells[0].Value; break; } } } //when code leaves these two loops (so comes here), the "total" local variable holds the result … | |
Re: maybe a bit off topic.. Momerath: ... StringBuilder!!! :) dont use any array, or "appanding" a text to a text, like myString +=something! :) I have learned that now. | |
Re: Mate, if this is not you final version of the project, I wont even help you out. That it wont be like last time, when I did the code for you (school homework I guess), and then you came out later to ungrade it. No, cant do. So, what is … | |
Re: Depents what type are these different versions. If they are both numbers you can use: ==, >=, <=, >, < (all of them). If they are a string you cannot use any. Becuase it will simply not work. YOu cannot compare the difference in the string, you can only compare … | |
Re: Read here: [url]http://www.codeproject.com/KB/database/DotnetDb2.aspx[/url] | |
Re: You have an error on row No.20. It should be like this: [CODE]dateTimePicker1.Value = Convert.ToDatetime(drr["BILL DATED"]);[/CODE] | |
Re: You want to do an sql query which would return all the order numbers, which contains the inserted number in textBox? The order is not counting at all? I can see you typed into a textBox 10078, and the return was 2 results: 1007851103 and 11007859. 2nd order number has … | |
Re: And what would you like to know? Only if they are equal? Or to the the same values back (or to get the vlaues which are not in both array)? Mitja | |
Re: Impossibe in these kind of collections. You cannot store type string into type of variable. What do I mean: your 1st array has the string as for a key, and 2nd array`s Value is the double. Chanage that. Then you simply code the key from array1 to the value of … | |
Re: Hi, you have to create a new Form. Create a method which would start the searching. Before search begins, start a new thread (so the main one will not be busy while searching). Then create a progressBar, which would show the progress (loading bar). Somehow you have to figue out … | |
Re: Please remember shyla, one question per thread. MArk this one as salved (vote as useful to those guys who answered on your question), and mark the whole thread as answered.! Remember, ONE question per thread. Bye | |
Re: In here: [CODE] using (TextReader rdr = new StreamReader(@"C:\"text.txt")) { //code in here } [/CODE] | |
The End.