1,469 Posted Topics
Re: Here you go: [CODE] Random r = new Random(); public Form1() { InitializeComponent(); label1.Text = "Which is the 3rd planet from the sun?"; DeselectAll(); } private void DeselectAll() { RadioButton[] rbs = { radioButton1, radioButton2, radioButton3 }; foreach (RadioButton rb in rbs) { rb.Checked = false; rb.Text = ""; } … | |
Re: Change to: [CODE] enum PasswordScore { Blank = 0, VeryWeak = 1, Weak = 2, Medium = 3, Strong = 4, VeryStrong = 5 } private static PasswordScore CheckingPasswordStrength(string password) { int score = 1; if (password.Length < 1) return PasswordScore.Blank; if (password.Length < 4) return PasswordScore.VeryWeak; if (password.Length >= … | |
Re: Here is one simple example: [CODE] private void button1_Click(object sender, System.EventArgs e) { Stream myStream ; SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ; saveFileDialog1.FilterIndex = 2 ; saveFileDialog1.RestoreDirectory = true ; if(saveFileDialog1.ShowDialog() == DialogResult.OK) { if((myStream = saveFileDialog1.OpenFile()) != null) { // Code to … | |
Re: Hello would you mind telling to Sort what exactly? An array, listArray, generic list<T>, dictionary collections, or else? You have to be specific, and which technique do you want to use? For the Arrays there is a method "Sort" avaiable, then you have a Linq, a very powerful tool in … | |
Re: Hi, would you show me the code you have there? | |
Re: [CODE]cmbCourses.Items.Clear();[/CODE] method should clear all the items from comboBox. if not try with additional code ( both): [CODE]cmbCourses.SelectedIndex = -1;[/CODE] | |
Re: Or: [CODE] string example = "0123456789"; int count = example.Length; [/CODE] | |
Re: To add: [CODE] namespace yourproject { public class Program : Form { private Button NewGame; public Program() { InitializeComponent(); 1st you need to create a button: NewGame = new Button; NewGame.Location = new Point (100,100); NewGame.Text = "press me"; NewGame.Name = "button1"; NewGame.Size = new Size(40, 23); NewGame.Click += new … | |
Re: You can bind it (this is the best solution and th fastest). [CODE] dataGridView1.DataSource = new BindingSource(myDataSet.Tables["tableName"], null); [/CODE] Thats it! And the data will appear in the DGV. | |
Re: One more suggestion: You can create a report (Crystal Report would be perfect), pass data of label to it, design it by your needs, and print it out. Thats why Reports are made for. | |
Re: You have to specify the full path in the connection string, like on this example: [CODE] Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyFolder\MyDatabase.mdb;User Id=admin;Password=; [/CODE] C:\MyFolder\MyDatabase.mdb - is the full path. And if you have it stated this way in the connection string, the code will always go there, no where else. | |
Re: Why not? you only have to specify the connection string to this dataBase. Basicly you only have to change the path to it! | |
Re: You can do it more appropriate with creating its own method, and call it from your main one: [CODE] Private Sub MyMethod() Dim toCheck As String = "someValue" Dim bChecking As Boolean = Checking(textBox1.Text, toCheck) If bChecking Then MessageBox.Show("Values are equal.") Else MessageBox.Show("Values are different.") End If End Sub Private … | |
Re: You forgot to specify where these files are gonna be selected. Is this a listBox, listView, or something else? If this is a listBox you can do: [CODE]int filesSelected = listBox1.SelectedIndices.Count;[/CODE] | |
Re: I dont really get yout question. Is it that you cant retreive the stirng of the subitem (the path of the subtitle)? To get subitem you do: [CODE]string path = listView.SelectedItems[0].SubItems[1].Text;[/CODE] | |
Re: Remove brackets: [CODE]string All = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789`~!@#$%^&*()_-=+[]{};:'|/?.>,<";[/CODE] and the for the All you have to assign index with [] brackers: [CODE] Password = Password + All[rdmNumber]; [/CODE] | |
Re: try this out: [CODE] class Program { static void Main(string[] args) { Program p = new Program(); //p.InsertDoc(); //p.RetriveDoc(); Console.Read(); } public void InsertDoc() { byte[] doc = GetDocFromHDD(@"C:\Users\Radwan\Documents\Test.doc"); OleDbConnection Conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; User Id=;Data Source=C:\\Users\\Radwan\\Documents\\Database1.mdb"); OleDbCommand addDoc = new OleDbCommand("insert into table1 (data,fileLength) values(@doc,@length)", Conn); OleDbDataAdapter MyDataAdapter = … | |
Re: You want that the ColumnHeader of one column in the DGV shows the time? and the time in thr real time? | |
Re: just after you populate the comboBox, call this property: [CODE]comboBox1.SelectedIndex = -1;[/CODE] This way the by default will nothing be selected. But this will only work if you populate comboBox manually; that means that the comboBox is not data bound. I didnt really get you what do you want. If … | |
Re: To get the path toapplication you can try on of these: [CODE] Dim Path1 As String = Application.StartupPath Dim exe As System.Reflection.Assembly = System.Reflection.Assembly.GetEntryAssembly() Dim Path2 As String = System.IO.Path.GetDirectoryName(exe.Location) Dim Path3 As String = Path.GetDirectoryName(Application.ExecutablePath) Dim path4 As String = Path.GetDirectoryName(Assembly.GetAssembly(GetType(Form1)).CodeBase) Dim strAppDir As [String] = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase) Dim strFullPathToMyFile … | |
Re: What do you mean? Can you explain your issue a bit better? And about which Tabs are you talking about? Of TabControl control? | |
Re: You can simple use a StreamWriter object in the else block [CODE] using (StreamWriter sw = File.AppendText(@"C:\1\log_1.txt")) { sw.WriteLine(value); } [/CODE] | |
Re: First you have to create a global TextBox variable array, so in the whole class is visible. Then create textboxes, and when you need to loop through them, do the following (code at the bottom): [CODE] TextBox[] tbs; void CreatingTextboxes() { tbs = new TextBox[int.Parse(numericUpDown.Value)]; //now loop with your code … | |
Re: Hi, what allignment is concerned, I would strongy suggest to use some other control like listView, or dataGridView. What do you think? YOu can still edit data there. | |
Re: Check out this code to remove duplicates: [CODE] int[] s = { 1, 2, 3, 3, 4}; int[] q = s.Distinct().ToArray(); [/CODE] | |
Re: If I look into your string query (INSERT INTO...) you always through the loop insert the same values. I thnik this is not the point here, or am I wrong? Anyway, you can do the loop something like this, but you will have to get new values for ID and … | |
Re: [CODE] for(int i = 0; i< listBox1.Items.Count; i++) { if(listBox1.Items[i] == textBox1.Text) { //item found break; } } [/CODE] | |
Re: If you want to do a Math operations over some data, these data have to be a true numbers. You cannot do math operations over strings (like the text property provides of the textBox). You can do: [CODE] int value1 = int.Parse(textBox1.Text); int value 2 = int.Parse(textBox2.Text); //put a result … | |
Re: You can even try it this way: [CODE] Dim sb As New StringBuilder() For i As Integer = 0 To listView1.Items.Count - 1 sb.AppendLine() For j As Integer = 0 To listView1.Columns.Count - 1 sb.Append(listView1.Items(i).SubItems(j).Text) If (i + 1) < listView1.Items.Count OrElse (j + 1) < listView1.Columns.Count Then sb.Append(",") End … | |
Re: Try splitting it(as said in the post abouve with th Split method. And do it like: [CODE] while (reader.Read()) { string[] array = reader[0].ToString().Split(','); foreach (string item in array) lstPK.Items.Add(item); } [/CODE] Even if there will be no comma in the string, there will always be one item to add … | |
Re: You mean to get all values from all columns and add them into one cell? Into same dataGridView or into some other one? | |
Re: [CODE] int rowsCount = cmd.ExecuteNonQuery(); [/CODE] | |
Re: Check here: [url]http://ebersys.blogspot.com/2006/08/arrays-of-methods-in-c.html[/url] | |
Re: To read the last record from the DB you do: [CODE]"SELECT MAX(ColumnName) FROM MyTable"[/CODE] And because this is a string (varchar) format, you 1st have to retreive the number out of the string, convert it to number (int), then do the incrementation (auto add 1) and convert it back to … | |
Re: So, what is the problem here? This has got to work: [CODE] //clear the items if they exist: ListView.Items.Clear(); DataTable dtable = myDataSet.Tables["CoffeeTypes"]; //Display items in the listview ctrl. foreach (DataRow drow in myDataSet.Tables) { ListViewItem lvi = new ListViewItem(drow["CoffeeID"].ToString()); lvi.SubItems.Add(drow["coffeeName"].ToString()); lvi.SubItems.Add(drow["coffeePrice"].ToString()); lvi.SubItems.Add(drow["coffeeStrength"].ToString()); lvi.SubItems.Add(drow["Origin"].ToString()); lvi.SubItems.Add(drow["QuantityInStock"].ToString()); listView1.Items.Add(lvi); } [/CODE] | |
Re: Check this out: But be careful with the column number (as far as I can see you assign date value to 14th subitem - mine is on 2nd (Subitems[1]): [CODE] Public Sub New() InitializeComponent() listView1.Columns.Add("Id", 50, HorizontalAlignment.Left) listView1.Columns.Add("Date and time", -2, HorizontalAlignment.Left) listView1.View = View.Details listView1.FullRowSelect = True 'add example … ![]() | |
Re: Hi, it hard to tell what could be done better. There is to much to learn. This code looks ok, and it works, but I dont know exaclty what do you want to do with it. | |
Re: You can have (use) only one connection through all the code, and ONLY one connection string. It would be even better to create connection string as global (too seeable in the whole class and static): Take into yours changed code: [CODE] static string connString = "SERVER=44.6.53.34;User=sa;password=56fgq3546fd5qFDGF;Database=addressstagingtable"; private void xmlBTN_Click(object sender, … | |
Re: Hi, are you talking about "saving" into dataBase? This like of code: [CODE]ds.Tables("CakePie").Rows.Add(dsnewrow)[/CODE] Inserts a new line to a dataTable CakePie, and it when with the line bellow (ds.Update) it gets inserted into the dataBase. When you do the Selection ones agiain, the last inserted value in now in the … | |
Re: I should work. Take a look at this simple example: [CODE] class MyClass { string a; //this will not be initialized, but there will be no error in compile time string b = "b"; public void MyMethod() { a = "a"; string c; //this will not be initialized, but there … | |
Re: On the button click event 1st delete all what you want (textBox content), and then populate it again. Simple. | |
Re: Check it out here: [url]http://www.sqlusa.com/bestpractices2005/centurydateformat/[/url] Its all written. | |
Re: Maybe you are forgetting double quotes on both side of the variable: [CODE] SqlDataSource1.SelectCommand = SELECT event, athname, D_ate, TIME1 FROM TableName WHERE event='" & dist & "' AND athname = '" & users & "'" [/CODE] | |
Re: Hi, one thing: a "list" as you have stated - it canNOT have checkBoxes at all. It can only contain some boolean values. So, in your code you have a generic list<T> with a custom class "filterHistory". This is a class which has a boolan property - for the checkBox … | |
Re: Create a get;set; modifier and access to in from both classes. [CODE] //main form: public static intSaldo { get; set; } //set it on a button click: intSaldo = int.Parse(textBoxSaldo.Text); //read it when you want (when comming back to main form): private void ReadSaldo() { int _saldo = intSaldo; //do … | |
Re: The code looks fine. Where should be the problem? Into this code you got the customers with their data: [CODE] Customer cust = new Customer(); SortedList custList = cust.ListCustomerByPostcode(ECenterPostcodeTextBox.Text); //custList hold now customers data!! //now you want to put them to listBox! //you will have to loop through the list … | |
Re: HttpContext.Current.Request.UserHostAddress This doesn't attempt to take into account proxies. For that, you can use Request.ServerVariables["HTTP_X_FORWARDED_FOR"]. However, make sure you're not trusting that blindly, since it could be forged. It's better to keep a whitelist of IPs for which you trust it. Other example: [CODE] String strHostName = new String(""); // … | |
Re: Sorry, but it would be good to give us more information. From that its impossible to figure out what would you like to have... but let me try to explain. Your example shows an Inheritance yes. It means that all the public fields, properties, methods in BankAccount, will be accessable … | |
Re: Sure it is: [CODE] Rabit[] rabits = new Rabit[10]; Fox[] foxes = new Fox[6]; Dog[] dogs = new Dog[4]; for(int i = 0; i < 10;i++) { Rabit r = new Rabit(); rabits[i] = r; if(i < 6) { Fox f = new Fox(); foxes[i] = f; } if(i < … | |
Re: So you only have to remove pictureBoxes, and lables? All of them? Because you have to be very specific which controls to remove. |
The End.