Mitja Bonca 557 Nearly a Posting Maven

Exactly, provide us a code that causes issues to you. Then we can show (explain) what is or might be wrong with it.

Mitja Bonca 557 Nearly a Posting Maven

Is this some column name of some collection object? Maybe you should use indexes instead.
Tell us more aobut it.

Mitja Bonca 557 Nearly a Posting Maven

Use a break point, and tell us where exactly the error occurs.

Mitja Bonca 557 Nearly a Posting Maven

Do it like:

    System.IO.DirectoryInfo downloadedMessageInfo = new    DirectoryInfo(GetMessageDownloadFolderPath());

foreach (FileInfo file in downloadedMessageInfo.GetFiles())
{
    file.Delete(); 
}
foreach (DirectoryInfo dir in downloadedMessageInfo.GetDirectories())
{
    dir.Delete(true); 
}

or:

public void DeletingFilesAndFolders(DirectoryInfo directory)
{
    foreach(System.IO.FileInfo file in directory.GetFiles()) file.Delete();
    foreach(System.IO.DirectoryInfo subDirectory in directory.GetDirectories()) subDirectory.Delete(true);
}
Mitja Bonca 557 Nearly a Posting Maven

Waht do you mean textarea (data in textarea? what is this? Do you mean TextBox controls?
If so you can check:

 bool bCheckTextBoxes = this.Controls.OfType<TextBox>().Any(a => string.IsNullOrEmpty(a.Text));
if (!bCheckTextBoxes)
{
     MessageBox.Show("Not all textBoxes are fulfiled.");
}

And which specific column? I am not sure what do you mean. Can you be please more exact?
thx

Mitja Bonca 557 Nearly a Posting Maven

As momerath stated, you need differenrt approach then in Console. You need some controls, where you will insert your data (exchange Textbox control for Console.ReadLine() method).
Then insert a Label, where yo will show results (exchnage for Console.WriteLine() method).
And use same method as you are using now for do the calculation.

Mitja Bonca 557 Nearly a Posting Maven

list item #1 = array(112, Maxwell Smart, MIS)
list item #2 = array(208, Bubba Joe, BNJ)
list item #3 = array(407, Mary Poppins, MEP)

Use Linq, and its Extension methods:
Example:
you add:

List<string[]> list = new List<string[]>();
list.Add(new string[] {"112", "Maxwell Smart", "MIS"});

and others...
now you would like to sort by last index of array - this are data MIS, BNJ and MEP (if Im correct).

---
The best way would be to create a new class and create 3 propertis inside of it (number, name and abbreviation, then fill it with the data from your array (or you can do it directly, so you wont have 2 lists.
This is how you can do:

class Person
{
    public int Number {get;set;}
    public string Name {get;set;}
    public string Abbreviation {get;set;}
}

Now create a list and fill it up from your current list:

List<Person> list2 = new List<Person>();
foreach(string[] data in list)
{
    list2.Add(new Person{Number = int.Parse(data[0]), Name = data[1], Abbreviation = data[2]});
}

now you can sort it:

var query = list2.OrderBy(o => o.Abbreviation).ToList();
Mitja Bonca 557 Nearly a Posting Maven

I dont get your point. What would you like to do exactly? Tell us the pattern why not adding a Beef as well?

Mitja Bonca 557 Nearly a Posting Maven

The getters and setters are only for the variables. If you want to create an object, you always need a constructor.

No, not true. Constructor is just some method (like all others) that are access before any other. Only the static constructor is called before it (but this is not out debate now).

As said, you dont need not get,set accessors, nor constructor(s) of a class. You can simply have fields (like you have) and public (or private) methods. Public can be access from other classes, while private cannot (only from inside this class. There are even protrected members of a class, that can be access from derived classes (from this one).

Mitja Bonca 557 Nearly a Posting Maven

Why dont you tell us exactly what is troubling you. You are the one who needs it to be done, not we.
And you came with a manner, like we have to correct it, so dont expect from any of us to do the whole code instead of you. We are here to help, not to do the code instead of you.

------

One thing to mention, your Students class has no constructor, so you cannot pass any argument to ti, like you did:

  M[i] = new Students(n); //incorrect
  //correct way according to your code is:
  M[i] = new Students();

One more thing, you better needa course class, and a grate.
Because one student has one or more courses, and each course can have one or more grades.
If you want to make it right.
Else tell your teacher she needs some more work to do :)

Mitja Bonca 557 Nearly a Posting Maven

Using some Regex will do:

Dim text As String = "<td class=""bld""><span id=""ref_12590587_l"">5,304.48</span>"
Dim regularExpressionPattern As String = "\>(.*?)\<"
Dim re As New Regex(regularExpressionPattern)
Dim dec As Decimal
Dim str As String = ""
For Each m As Match In re.Matches(text)
    str = m.Value.Replace(">", "").Replace("<", "")
    If str.Length > 0 Then
        If str.Contains(",") Then
            str = str.Replace(",", "")
        End If
    End If
Next
Begginnerdev commented: Good job, Mitja. +5
Mitja Bonca 557 Nearly a Posting Maven

sure, loop through the rows, and check the columns you have a condition, and set ReadOnly to true:

 For Each row As DataGridViewRow In dgv.Rows
    If row("ConditionColumnName").Value.ToString() = "your condition" Then
        row.[ReadOnly] = True
        'you can even color the row differently
        'like:
        row.DefaultCellStyle.BackColor = Color.Red
    Else
        row.[ReadOnly] = False
            'normal color
        row.DefaultCellStyle.BackColor = Color.White
    End If
Next
Mitja Bonca 557 Nearly a Posting Maven

No problem, any time actually :)

Mitja Bonca 557 Nearly a Posting Maven

In this case, we have to re-do your code completely. Usin some Linq and an additional method. I did think of something like this:

        private void YourMethod()
        {
            double media = 1.8815;
            List<double> lista = new List<double>();
            lista.Add(2.201);
            //and other values...

            List<double> aux = new List<double>();
            for (int i = 0; i < lista.Count; i++)
            {
               if(CheckNext5(media, lista.Skip(i).Take(5).ToList()))
               {
                   for (int j = 0; j < 5; j++)
                       aux.Add(lista[i + j]); 
                   i = i + 4;
               }
            }
        }

        private bool CheckNext5(double media, List<double> list)
        {
            bool bFlag = true;
            foreach (double item in list)
            {
                if (item < media) 
                {
                    bFlag = false;
                    break;
                }
            }
            return bFlag;
        }

There is a method, that checked next 5 values if they are higher then the media variable, is so, they are added to the new list, else, loops goes on to get next values.
ps: vote and add a comment :)

Hope you like it :)

Mitja Bonca 557 Nearly a Posting Maven

You means to add all numbers (of 5 in a row) if higher then the media into new list?

Mitja Bonca 557 Nearly a Posting Maven

Specify them as string and use @ simbol infront of the variable - so the string will be take exactly as it is - no escape characters will be used and add 2 quotations marks on the end to use last quote in the string:

Dim myChars As String = "@#$%^&&*"""
Mitja Bonca 557 Nearly a Posting Maven

You simply specify the columns name you want to seach by in the WHERE clause, and define it as parameter of the query:

DataTable table = new DataTable();
OdbcConnection conn = new OdbcConnection("connString");
string query = @"SELECT * FROM Person WHERE LastName = @last";
OdbcCommand cmd = new OdbcCommand(query, conn);
cmd.Parameters.Add("@last", SqlDbTyple.VarChar, 50).Value = textBox1.Text;
OdbcDataAdapter da = new OdbcDataAdapter(cmd);
da.Fill(table);

Now your table has all the rows from the table, based on the lastnames (the rows that have this name written in textbox

Mitja Bonca 557 Nearly a Posting Maven

If so, you can do it like:

List<double> aux = new List<double>();
int counter = 0;
for (int i = 0; i < lista.Count; i++) 
{
    if(counter == 5)
        break;
    if(lista[i] > media && counter <= 5)
    {
        aux.Add(list[i]);
        counter++;
    }   
    else
    {
        counter = 0;
        aux.Clear();
    }
}

//show values...
chromatinpt commented: 1 +1
Mitja Bonca 557 Nearly a Posting Maven

It clears because cooner or later your code goes to else block, and clears the list.

But I actually dont get it which value would you like to put into aux list from lista. Can you clarify it a bit better?

Do you mean that tin the for loop you check the current value, and if this and next 5 values are higher then the media value, you put all these 5 values into aux list?
And you continue loopint to the end of the items in lista?

Mitja Bonca 557 Nearly a Posting Maven

1st of all, if you use radionButton, there is always one selected (its not the same as checkBoxes, where you can deselect all). Ok, its possible to deselect all radionButtons in a group as well, but this is not the purpose then in using radionButtons.

About showing the button control, when there is some text inside a textBox, you can use a Length property to check how long is the actual text, and show/hide button based on that - inisde the TextChanged event (just subscribe to in, on double clicking on it in winform designer:

private void textBox1_TextChanged(object sender, EventArgs e)
{
    if(textBox1.Text.Length == 0) //checking if there is any text inside textBox - if there is at least 1 character, buttoon will show up
    {
        button1.Visible = false;
    }
    else
    {
        button1.Visible = true;
    }
}
Mitja Bonca 557 Nearly a Posting Maven

loop through rows of gridview and check the column of checkbox (if checked (true) add to database, if not do nothing.

            foreach(DataGridViewRow row in dgv.Rows)
            {
                DataGridViewCheckBoxCell check = row.Cells[0] as DataGridViewCheckBoxCell; 
                //0 represents 1st column; change the index to your column
                if ((bool)check.Value)
                {
                    //insert this row (checkBox is checked
                }
            }
Mitja Bonca 557 Nearly a Posting Maven

Please provide us some deicent explanation if you want any help from us. These 2 images do nothing.

Mitja Bonca 557 Nearly a Posting Maven

why would you combine two datetimes?
Can you explain this better?

Mitja Bonca 557 Nearly a Posting Maven

I assume you are trying to create a code for checking the password strenght. Here is some of my code I used to have for it:

Private Enum PasswordScore
    Blank = 0
    VeryWeak = 1
    Weak = 2
    Medium = 3
    Strong = 4
    VeryStrong = 5
End Enum

Private Shared Function CheckingPasswordStrength(password As String) As PasswordScore
    Dim score As Integer = 1
    If password.Length < 1 Then
        Return PasswordScore.Blank
    End If
    If password.Length < 4 Then
        Return PasswordScore.VeryWeak
    End If

    If password.Length >= 8 Then
        score += 1
    End If
    If password.Length >= 12 Then
        score += 1
    End If
    If Regex.IsMatch(password, "[0-9]+(\.[0-9][0-9]?)?", RegexOptions.ECMAScript) Then
        'number only //"^\d+$" if you need to match more than one digit.
        score += 1
    End If
    If Regex.IsMatch(password, "^(?=.*[a-z])(?=.*[A-Z]).+$", RegexOptions.ECMAScript) Then
        'both, lower and upper case
        score += 1
    End If
    If Regex.IsMatch(password, "[!,@,#,$,%,^,&,*,?,_,~,-,L,(,)]", RegexOptions.ECMAScript) Then
        '^[A-Z]+$
        score += 1
    End If
    Return CType(score, PasswordScore)
End Function
Mitja Bonca 557 Nearly a Posting Maven

And you will populate (show) all bnames into textbox1, and all anames into textbox2?
How they will be seperated?
This is not a good idea, better use a listBox, so items will be in a seperated rows.

Mitja Bonca 557 Nearly a Posting Maven

Are these textBoxes on same form?
I would suggest you to create an array of textBoxes (in order, like you will populate them), and then just loop through them and fill text into each of them.
Example:

TextBox[] tbs;
public Form1()
{
    tbs = new TextBox[]{textBox1, textBox2, textBox3 }; //put all in here
}

public PopulateTextBoxes(string[] data)
{
       for(int i = 0; i < tbs.Lenght; i++)
       {
           tbs[i].Text = data[i];
       }
}

Call the method PopulateTextBoxes when you have all data gathered. I used string array, but you can have some other parameter, like a custom class, or what ever.

If there is so many textboxes, and this might consume some time to populate them all, you can create a new thread, and populate them there, but you will have to use delegates to do it so.

Mitja Bonca 557 Nearly a Posting Maven

This question has been asked a couple of times. Please do NOT duplicte threads. One will be just fine.
Close this one.

Mitja Bonca 557 Nearly a Posting Maven

Iam glad you found it. I told you there has to be some code that does changes.
From now on you will know where to look if this kind of issue appears.
bye

Begginnerdev commented: Good job Mitja! +5
Mitja Bonca 557 Nearly a Posting Maven

Show us your Designer code of the form (whole code).
Its hard to tell what can be wrong, but for sure there is some "additional" code that changes position of controls.

Mitja Bonca 557 Nearly a Posting Maven

Sure it does, you must have the correct connection string of your database. Are you sure you have one?
Which is exactly your database?

To answer on your last question, myComboBox is a reference (a reference name) to your ComboBox control.
When you create (instanitate) new comboBox control you do:
ComboBox comboBox1 = new ComboBox(); //is this example comboBox1 is same as myComboBox - its just a variable - name

But this code does C# automatically by it self when you add this control to the form. If you will look into Desiger of your form, you will see this code is there. And much more (like Size, Location, Index,...)

Hope it help explaining initial issues.

Mitja Bonca 557 Nearly a Posting Maven

You can use Remove method of String class with a help of a tag (your span tag of html):

            string pattern1 = @"<li>(.*?)</li>";
            string tag = "</span>";

            Regex regex = new Regex(pattern1);
            Match match = regex.Match(text);
            string myText = match.Groups[1].Value;            
            myText = myText.Remove(0, myText.IndexOf(tag) + tag.Length);
Mitja Bonca 557 Nearly a Posting Maven

But I guess you would like to get all whats inside li tags, so all within <li>...</li>? Am I correct?
If so, this is the pattern and the code you can use:

            string pattern = @"<li>(.*?)</li>";
            Regex regex = new Regex(pattern);
            //1. if one occurence in a string:
            Match match = regex.Match(text);
            if (match.Success)
            {
                string myText = match.Groups[1].Value;

                string[] twoData = myText.Split(',');
                foreach (string data in twoData)
                {
                    myText = data;
                }
            }
Mitja Bonca 557 Nearly a Posting Maven

or;

'1
Dim controls As TextBox() = Me.Controls.OfType(Of TextBox)().OrderBy(Function(o) o.Name).ToArray()
'then you can loop in foreach (like bellow)

'2.
For Each control As var In Me.Controls.OfType(Of TextBox)()
    Dim name As String = control.Name
Next
Begginnerdev commented: Good alternative! +5
Mitja Bonca 557 Nearly a Posting Maven

Like:

Using conn As New SqlConnection("connString")
    Using cmd As SqlCommand = New SqlComand("SELECT ColumnName FROM TableName", conn)
        Using reader As SqlDataReader = cmd.ExecuteReader()
            While reader.Read()
                comboBox1.Items.Add(reader(0).ToString())
            End While
        End Using
    End Using
End Using
Mitja Bonca 557 Nearly a Posting Maven

When do you add them exactly? I hope AFTER binding it. And I would use Insert method, not Add. Where you have to specify 2 arguments:
- DGV column reference
- index of column to insert (starting from 0 up (0 is 1st column, 1 is 2nd column,...)

But I can see you actually ADD coumns - they exist.
You even add data into those 2 new columns correctly.

What you dont do right, is that 2nd last line of code, where you are trying to get "...OwningColumn.HreaderText".
What is this actually?
Remove that line, and try it out ones again, or only retreive the value from the cell like:

     object val = dgvrow.Cells["PRG"].Value;
    string hdr  = dgvrow.Cells["PKG"].Value.ToString();
    MessageBox.Show(hdr + " val = " + val.ToString());
Mitja Bonca 557 Nearly a Posting Maven

Create it as a login form (in same way):

static class Program
{  
    [STAThread]
    static void Main()
    {   
        using (Splash splash = new Splash())
        {
            splash.StartPosition = FormStartPosition.CenterScreen;
            if (splash.ShowDialog() == DialogResult.OK) 
            {      
                 Application.Run(new Form1()); 
            }
        }
    }
}



//inside Splash form do:
//use some Timer or something, and after some time call this method:
private void StopSplashScreen()
{       
     this.DialogResult = DialogResult.OK; //this will exit login and start Form1
}
Mitja Bonca 557 Nearly a Posting Maven
Mitja Bonca 557 Nearly a Posting Maven

You dont need to convert it, but you simply bind it to dgv. Using dataSource property of dgv, assgin dataTable to it:

dgv.DataSource = dataTable.DefaultView;
Mitja Bonca 557 Nearly a Posting Maven

Loop through the rows of particular column:
1.

    List<string> usersOver30  = new List<string>();
    foreach(DataGridViewRow row in dataGridView1.Rows)
    {
         int age = 0;
         if(int.TryParse(row["Age"].Value.ToString(), out age))
             if(age >= 30) 
                  usersOver30.Add(row["Name"].Value.ToString();
    }
    //list contains all names of users that are over 30 years old

2.

foreach(DataGridViewRow row in dataGridView1.Rows)
{
     DataGridViewCell cell = row["Asset"] as DataGridViewCell;
     int asset = 0;
     if(int.TryParse(cell.Value.ToString(), out asset))
         if(asset < 500) 
              cell.Value = (asset + 100).ToString();
}
Mitja Bonca 557 Nearly a Posting Maven
Mitja Bonca 557 Nearly a Posting Maven

If there is any field in your database (all others then varchar - string actually) you must provide this type.
I see you provide for example "xyz" parameter, which is (surely) an integer, you have to convert string to integer (thats why you got this kind of exception).
so like (if xyz is non a string)

"... WHERE StudentNumber = '" + Convert.ToInt32(xyz) + "'";

Mitja Bonca 557 Nearly a Posting Maven

It sulely cant work this way, your class reference is not accessable. You created and instantiated new class refercne in Form1 constructor. You must define it on a class level, so it can be accessed in your RedCheckBox_CheckedChanged event, like:

Events redEvent; //define class on a class level!
public Form1()
{
    InitializeComponent();
    redEvent = new Events();
}

private void RedCheckBox_CheckedChanged(object sender, EventArgs e)
{
    redEvent.RedCheckBoxEvent();
}

Hope it helps,
bye

Mitja Bonca 557 Nearly a Posting Maven

Yes and your exact question would be?
Show us some example code, with the calculations, I mean.

Mitja Bonca 557 Nearly a Posting Maven

your should names your table, but else to get them all out, you can use "ALL" witj * simbol:

SELECT * FROM information_schema.tables WHERE table_type = 'BASE TABLE'
Mitja Bonca 557 Nearly a Posting Maven

Whole code would be:

string connectionString = "Data source=localhost;Database=locations;user id=root;password=ietmdb;";
DataTable tables = new DataTable("Tables");
using (SqlConnection connection = new SqlConnection(connectionString))
{
    using(SqlCommand command = connection.CreateCommand())
    {
        command.CommandText = "select table_name as Name from INFORMATION_SCHEMA.Tables where TABLE_TYPE = 'BASE TABLE'";
        connection.Open();
        tables.Load(command.ExecuteReader(CommandBehavior.CloseConnection));
    }    
}

foreach(DataRow row in table.Rows)
{
    DropDownList1.Items.Add(row[0].ToString());
}
Mitja Bonca 557 Nearly a Posting Maven

try using this select query statement:

"select table_name as Name from INFORMATION_SCHEMA.Tables where TABLE_TYPE = 'BASE TABLE'";
Mitja Bonca 557 Nearly a Posting Maven

use for loop, but instead of incrementing +1, do the reverse operation, so each step -1:

            for (int i = dgv.Rows.Count; i > 0; i--)
            {
                DataGridViewRow row = dgv.Rows[i] as DataGridViewRow;
                //use row for your insertion
            }
Mitja Bonca 557 Nearly a Posting Maven

Why so much code needed to paste it here? Next time paste only the code needed. Ok?
Ok, to thread`s topic:
Create an array of images (Bitmap or Image classs). Put a timer (System.Windows.Timer for instance) and initialize it. Set some properties, like the Interval (on how many time the event will rise), subscribe to TICK event (use timer1 += new EventHandler(makeOfMethod);) and then start it when even you need.
Inside the tick event create a for loop of all images and use by one one:

for(int i = 0; i < imageArray.Length; i++)
    pictureBox.Image = imageArray[i];

You can set some other parameters like image size and others.

Mitja Bonca 557 Nearly a Posting Maven

skatamatic:
1st and 2nd examplea are equl (since you used logical OR operator, and braces does not make any difference.
While 3rd example is different: it says: loop while t3 and any of t1 or t2 are alive - use this example if you wanna check if your t3 is alive or not.
Or if you wanna check if all are alive

while (t3.IsAlive && t2.IsAlive && t1.IsAlive)
Mitja Bonca 557 Nearly a Posting Maven

And your question is?
You know, we wont do the code instead of you - be sure about that. So if you need any help, ask us, and would be more the glad to help.