1,469 Posted Topics

Member Avatar for Phil++

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 = ""; } …

Member Avatar for Thijk
0
107
Member Avatar for anish99virgo

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 >= …

Member Avatar for anish99virgo
0
6K
Member Avatar for vincezed

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 …

Member Avatar for vincezed
0
127
Member Avatar for virendra_sharma

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 …

Member Avatar for virendra_sharma
0
176
Member Avatar for alexaaxela
Member Avatar for Farhad.idrees

[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]

Member Avatar for Farhad.idrees
0
5K
Member Avatar for WolfShield

Or: [CODE] string example = "0123456789"; int count = example.Length; [/CODE]

Member Avatar for WolfShield
0
194
Member Avatar for jmurph333

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 …

Member Avatar for jmurph333
0
2K
Member Avatar for xanawa

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.

Member Avatar for xanawa
0
105
Member Avatar for missc

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.

Member Avatar for missc
0
113
Member Avatar for AmIAyTi

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.

Member Avatar for Mitja Bonca
0
102
Member Avatar for AmIAyTi

Why not? you only have to specify the connection string to this dataBase. Basicly you only have to change the path to it!

Member Avatar for Mitja Bonca
0
52
Member Avatar for ryan311

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 …

Member Avatar for Mariandi
0
333
Member Avatar for nore

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]

Member Avatar for Mitja Bonca
0
141
Member Avatar for Razer_90

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]

Member Avatar for abelLazm
0
138
Member Avatar for Trle94

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]

Member Avatar for Mitja Bonca
0
171
Member Avatar for bia

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 = …

Member Avatar for Mitja Bonca
0
565
Member Avatar for xanawa

You want that the ColumnHeader of one column in the DGV shows the time? and the time in thr real time?

Member Avatar for xanawa
0
216
Member Avatar for c#Programmer

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 …

Member Avatar for Mitja Bonca
0
170
Member Avatar for ashwinshenoy

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 …

Member Avatar for Mitja Bonca
0
265
Member Avatar for Tazsweet19

What do you mean? Can you explain your issue a bit better? And about which Tabs are you talking about? Of TabControl control?

Member Avatar for Mitja Bonca
0
60
Member Avatar for Arjun_Sarankulu

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]

Member Avatar for Mitja Bonca
0
134
Member Avatar for Hellborg

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 …

Member Avatar for Mitja Bonca
0
207
Member Avatar for shyla

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.

Member Avatar for shyla
0
108
Member Avatar for RunTimeError

Check out this code to remove duplicates: [CODE] int[] s = { 1, 2, 3, 3, 4}; int[] q = s.Distinct().ToArray(); [/CODE]

Member Avatar for MvKTheBoss
0
426
Member Avatar for somemightsay

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 …

Member Avatar for Mitja Bonca
0
139
Member Avatar for Behseini

[CODE] for(int i = 0; i< listBox1.Items.Count; i++) { if(listBox1.Items[i] == textBox1.Text) { //item found break; } } [/CODE]

Member Avatar for Mitja Bonca
0
172
Member Avatar for ndeniche

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 …

Member Avatar for Mitja Bonca
0
283
Member Avatar for ryan311

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 …

Member Avatar for Mitja Bonca
0
138
Member Avatar for Behseini

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 …

Member Avatar for Behseini
0
214
Member Avatar for xanawa

You mean to get all values from all columns and add them into one cell? Into same dataGridView or into some other one?

Member Avatar for xanawa
0
106
Member Avatar for TheJohnSpecko
Member Avatar for choover12

Check here: [url]http://ebersys.blogspot.com/2006/08/arrays-of-methods-in-c.html[/url]

Member Avatar for Mitja Bonca
0
73
Member Avatar for lianpiau

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 …

Member Avatar for lianpiau
0
2K
Member Avatar for lightshift

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]

Member Avatar for kitjo
0
150
Member Avatar for Dorayaki

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 …

Member Avatar for Unhnd_Exception
-1
3K
Member Avatar for spunkywacko

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.

Member Avatar for spunkywacko
0
96
Member Avatar for moone009

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, …

Member Avatar for Mitja Bonca
0
151
Member Avatar for lielee

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 …

Member Avatar for P.manidas
0
151
Member Avatar for spunkywacko

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 …

Member Avatar for spunkywacko
0
95
Member Avatar for sushanth08

On the button click event 1st delete all what you want (textBox content), and then populate it again. Simple.

Member Avatar for Mitja Bonca
0
101
Member Avatar for xanawa

Check it out here: [url]http://www.sqlusa.com/bestpractices2005/centurydateformat/[/url] Its all written.

Member Avatar for xanawa
0
319
Member Avatar for taxmybrain

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]

Member Avatar for aspproject
0
161
Member Avatar for JakeA

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 …

Member Avatar for Mitja Bonca
0
191
Member Avatar for Robert955

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 …

Member Avatar for Robert955
0
236
Member Avatar for johnt68

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 …

Member Avatar for johnt68
0
207
Member Avatar for adobe71

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(""); // …

Member Avatar for aspproject
0
102
Member Avatar for james6754

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 …

Member Avatar for Momerath
0
118
Member Avatar for TheBadger

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 < …

Member Avatar for Mitja Bonca
0
161
Member Avatar for TheBadger

So you only have to remove pictureBoxes, and lables? All of them? Because you have to be very specific which controls to remove.

Member Avatar for Mitja Bonca
0
131

The End.