1,469 Posted Topics
Re: [QUOTE=Momerath;1479549]Instead of creating a new class and methods to fill the class we can use LINQ to do that for us: [code]var allItems = item.Zip(location, (i, l) => new {Item = i, Location = l});[/code][/QUOTE] Interesting... but there is some code missing. Would you mind showing it all? I mean, … | |
Re: For login ordinary we have userName and password. So for checking if user exist in the database you only chack for these 2 parameters. So: [CODE] SELECT UserName, Password FROM Users WHERE UserName = 'textBoxUserName.Text' [/CODE] Now you open an sqlDataReader which wil check if the userName exists. If exists … | |
Re: And what exactly would you like to search? Tell me more. Mitja | |
Re: 1st: you code of selected item is incorect, you have to check for "Selected" property, not "Checked". Checked property is especially used for checkBoxes. | |
Re: This how: [CODE] public partial class Form1 : Form { List<string> listNames; public Form1() { InitializeComponent(); //some example data to populare dgv: dataGridView1.Columns.Add("col1", "name"); dataGridView1.Columns.Add("col2", "age"); dataGridView1.Rows.Add("mitja", "31"); dataGridView1.Rows.Add("john", "28"); dataGridView1.Rows.Add("sara", "22"); } private void button1_Click(object sender, EventArgs e) { listNames = new List<string>(); foreach (DataGridViewRow row in dataGridView1.Rows) { … | |
Re: Added to darkagn`s post... you can bind listBox control to the datasource (and tabControl as well), which hold some data (the control will get populated "automactically". Back to your question. If I understood you, You have a textBox, into which user enters some name, this name then transfers to listBox, … | |
Re: Look at this code, it creates and erases (if exist) all labels: [CODE] Label[] label; int counter = 1; private void button1_Click(object sender, EventArgs e) { //checing if labels already arecreatred: if (label != null) ClearingLabels(); //next: creating new labels: int x = 20; int y = 20; label = … | |
Re: Convert the value to integer, and you should have the correct value, like: [CODE] private void numericUpDown1_ValueChanged(object sender, EventArgs e) { int value = Convert.ToInt32(this.numericUpDown1.Value); }[/CODE] | |
Re: Hi, I guess you want to do the sql query on every character inserted, but... You missed the point of the main issue you are having. Tell me, which characters do you want to be inserted into textBox (or which not)? As far as I can see from your code … | |
Re: Heres all you need: [CODE] private void button1_Click(object sender, EventArgs e) { //changing name and text property of the tabPage1 (of the tabContgrol1): tabPage1.Name = String.Empty; tabPage1.Text = "LOOK"; //creating new tabPage (of th tabControl1): int countPages = tabControl1.TabPages.Count; TabPage newPage = new TabPage(); newPage.Name = "tabPage" + countPages; newPage.Text … | |
Re: Hi again, it would help if you would paste the code that you have in here, it will be a way easier salved. HINT: ayou said you can bind Names to the listBox, so when you want to bind "SureNames", 1st you set the dataSource to null (to clear it) … | |
Re: In form load write: [CODE]this.FormBorderStyle = FormBorderStyle.None;[/CODE] | |
Re: [CODE] string dayOfWeek = DateTime.Now.DayOfWeek.ToString(); [/CODE] | |
Re: [CODE] if (db.dbRdr.Read()) { textBox1.Text = (string)dbRdr[0]; } [/CODE] YOu simply have to specify the type of tghe db`s column to the reader, and pass th value to the variable - in your case this is the control textBox1. Hope it helps, Mitja | |
Re: [URL="http://dotnetperls.com/streamwriter"]Here[/URL] you have simple examples of using StreamWriter, which is in your case by far best object to use. And [URL="http://msdn.microsoft.com/en-us/library/system.io.streamwriter.aspx"]here[/URL] you can read about StreamWriter class. Its good to know which metods and properties to use with this object. Hope it helps, Mitja | |
Re: Hi, of course its possible to do games with C# -everything you can image. Here is a link to your game: [url]http://forum.codecall.net/csharp-tutorials/1804-code-c-tic-tac-toe.html[/url] Hope it helps, Mitja | |
Re: Which adjacent label? The closest one on all four sites (up, down ,left and right)? Please defile which one the code needs to check Precisly. Mitja | |
Re: Try to remove that auto sizing. Leave the sizining on default. | |
Re: hmm, you have to specify the full path to the database, like: [CODE] string connString = "Data Source=localhost; Database=C:\MyFolder\MyProject\Database1.mdf; User ID=root; Password=root"; [/CODE] If not, you can use instead of a full path, implicit path: "|DataDirectory|\.Database1.mdf" | |
Re: As said, its the same thing. but I would go for 1st choice. Why? Simply because its better looking, and easier for recognizing parameters. But its up to you which one you will pick. Mitja | |
Re: You want to create 20 centances. is there any pre-defined order of the array? I mean has to code pick one item from 1st array, then one item from 2nd array, one item from 3rd array and one item from 4th array? Or can be custom? | |
Re: This might help. I put the code into a button click event, you can put it anywhere you want to: [CODE] private void button1_Click(object sender, EventArgs e) { //test code: textBox1.Text = "only girl"; textBox2.Text = "rihanna"; //your code: string webAddress = "http://www.youtube.com/results?search_query="; TextBox[] tb = new TextBox[] { textBox1, … | |
Re: You can do it like this: [CODE] int[] array = new int[25]; Random random = new Random(); // insert 25 random integers from 0-99 in tree for ( int i = 0; i < 25; i++ ) { int value = random.Next(0,101); array[i] = value; } //sort in ascending order: … | |
Re: Do you already have create database in Sql Server? Which sql server will you be using exactly? | |
Re: You want that user write number by number (one per each time) and the app. should create an array? | |
Re: What do you means with using SQL? Sql has nothing do to with programming. Its only meant for saving some data, which can be retreived and processed by the program. But not with sql. Sql is so called dataBase to which you can approach with many kind of quieries (select, … | |
Re: Here is an example, that might help: [CODE] using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Feb17Exercise { public partial class Form1 : Form { public Form1() { InitializeComponent(); // Create the customer object we want to display Customer bill = … | |
Re: In foreach loop: [CODE] List<RangeChecker> range = new List<RangeChecker>(); //then you fill the list! for(int i = 1; i< 5; i++) { RangeChecker rr = new RangeChecker(); //i will insert some example data rr.Meter = i; rr.Yard = (i*0.9) range.Add(rr); } //read out of it: foreach(RangeChecker rc in range) { … | |
Re: No. So open that form2. We cannot know which one is that your "login Form", can we? | |
Re: And where do you instantiate the object, like: TBinarySTree bt; ? You can create a new instance of an object on two ways: [CODE] namespace ConsoleApplication1 { class MyClass { //1. in the class: BinarySTree bt = new TBinarySTree(); //2.In the method BinarySTree bt; private void MyMethod() { bt = … | |
Re: This should do it: [CODE] //on form1: Form2 f2 = new Form2(this); form2.Show(); //create a method and a label on Form1 //to pass data from form2 to form1; public void MyMethod(string value) { Label lablel1 = new Label1; label1.Location = new Point(10,10); this.Controls.Add(label1); label1.Text = value; } //on form2: //constructor … | |
Re: This should do it: [CODE] public partial class Form1 : Form { public Form1() { InitializeComponent(); string[] array ={"A", "B", "C", "D", "E"}; listBox1.DataSource = array; listBox1.SelectedIndex = -1; listBox1.SelectedIndexChanged+=new EventHandler(listBox1_SelectedIndexChanged); } private void button1_Click(object sender, EventArgs e) { //1. automatic selection - insert the number of the index into … | |
Re: [QUOTE=DeathEater;1472612]hi, i'm having a bit of trouble with grid views. see i can show stuff in them but i want to manipulate and use a certain selected record or field in it ( e.g : delete it from table in the DB or copy it into a textbox.). i'll be … | |
Re: This should work: [CODE] public enum Options { newZ = 1, display, Exit } void Method2() { string volString = "1"; Options options = (Options)Enum.Parse(typeof(Options), volString); switch (options) { case Options.newZ: { break; } } } [/CODE] | |
Re: This is partly true (decimals will not go through, while negative integers will go): [CODE] try { numberToFactoral = int32.parse(textbox1.text); } catch { label1.text = "please input positive whole number"; return; } [/CODE] If the user will enter "-1" will go through try block. Because its -1 is still a … | |
Re: Convert strings into integers and then do the comparison: [CODE] int intValueA = Convert.ToInt32(txtMath.Text); if (ibtValueA >= 80)[/CODE] | |
![]() | Re: Can you point me to the row where is comes to the error? Its hard to look in such a code, which has so many custom objects - it will take a lot of time to figure out what all you have there. thx Mitja ![]() |
Re: So you have 2 comboBoxes. 1st is bound to dataSource and 2nd comboBox is populated with some values, regarding on comboBox1 selection. Which values are these, what is seatNumber variable? Can you please provide some more code? thx mitja | |
Re: Do you have to save only names of th checkBoxes? or What exactly? And where? Do you need a new ID (primary key) for each checklistBox? How does your storedProcedure look like (it only accepty one value at a time, or..)? If its in any help: [CODE] private void GetCheckedItems() … | |
Re: Apparently you add data to dgv control from textBoxes. Every time you insert something into textBoxes, these data (2) have to insert into a new row in dgv. This is how you do it: [CODE] public partial class Form1 : Form { public Form1() { InitializeComponent(); dataGridView1.Columns.Add("col1", "column 1"); dataGridView1.Columns.Add("col2", … | |
Re: What exactly would you like to do? BTW: there are two sentances in the upper xml code. Which one? | |
Re: Can you insert 0 (zero) instead of nothing (in case if user does not insert a number)? I was thinking of using this code then: [CODE] string strValue = textBox1.Text.Trim(); int intValue = 0; if (strValue != String.Empty) intValue = Convert.ToInt32(strValue); else intValue = 0; [/CODE] | |
Re: Is there any other control on the form, you can set its primal focus? If you can try to set the focus to the form: this.Focus(); | |
Re: 1. You can create an array of all wanted textBoxes: [CODE] private void button1_Click(object sender, EventArgs e) { TextBox[] tb = new TextBox[] { textBox1, textBox2, textBox3, textBox4, textBox5 }; for (int i = 0; i < tb.Length; i++) tb[i].Text = String.Empty; } [/CODE] | |
Re: Where do you have defined "ShortName" property in the clsItemsNumID class? I dont see it. Do it this way: [CODE] public class clsItemsNumID { public string LongName { get; set; } public string ShortName { get; set; } public int ID { get; set; } public clsItemsNumID(int _id, string _long, … | |
Re: I did the example code, and it works fine. I have created two form (form1, and form2). Instead of using dropDownList, I have used ComboBox control - its actually the same, you only change the code so it will suit to your control. Ok here it is: //form1: [CODE] public … | |
Re: Here you do: [CODE] using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace Feb153TyperArch { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { BLL bll = new BLL(); List<Customer> … | |
Re: [QUOTE=AngelicOne;1473757]..., but the selection doesn't change from date picker only! I need an object that I can be able to choose both date and time.[/QUOTE] Can you please elaborate this issue a bit precisly? and this works: [CODE] DateTime date = dateTimePicker1.Value; string strDate = String.Format("{0:MM/dd/yy hh:mm tt}", date); [/CODE] … | |
Re: Yes and? Where from, the store, from the hill or from dataBase? Please privide us some more info. I cannot know what exactly do you hae in mind. Mitja | |
Re: [CODE] using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Feb15StingArray { class Program { char[] alphabet = "abcdefghijklmnopqrstuvwxyz".ToCharArray(); string[] lines = System.IO.File.ReadAllLines(@"C:\1\test4.txt"); string[] parts = null; static void Main(string[] args) { Program one = new Program(); one.splitData(); one.run(one.parts); Console.WriteLine(one.getValueForName("s")); Console.WriteLine("Press any key to exit."); System.Console.ReadKey(); } public void run(string[] … |
The End.