Mitja Bonca 557 Nearly a Posting Maven

I really dont know what you mean. I gave you the code, step by step. I dont know what would you like to have more - this is it mate!
If you would have any example about what you are talking, it would be easier....

Mitja Bonca 557 Nearly a Posting Maven

Which pseudo code? I dont understand.

Mitja Bonca 557 Nearly a Posting Maven

Keep what?
I actually didnt understand you well. Did you select any cells (or rows) before calling OnShown method?

Mitja Bonca 557 Nearly a Posting Maven

Why you dont name the differently? This is a stupid idea. And i dont even know how your code works.
but anyway, you can loop through them and do:

protected override void OnShown(EventArgs e)
        {
            foreach (Control c in this.Controls)
            {
                if (c is DataGridView)
                {
                    DataGridView dgv = c as DataGridView;
                    dgv[0, 0].Selected = false;
                }
            }
        }
Mitja Bonca 557 Nearly a Posting Maven

This will do to deselect all:

protected override void OnShown(EventArgs e)
        {
            dataGridView1[0, 0].Selected = false;
            dataGridView2[0, 0].Selected = false;
            dataGridView3[0, 0].Selected = false;
        }
Mitja Bonca 557 Nearly a Posting Maven

This might help:

dataGridView1.Rows[0].Cells[0].Selected = false;
Mitja Bonca 557 Nearly a Posting Maven
//sql query
string query = "SELECT * FROM MyTable";
//create connection
SqlConnection sqlConn = new SqlConnection("connString");
//create command
SqlCommand cmd  = new SqlCommand(query, sqlConn);
//create dataAdapter
SqlDataAdapter da = new SqlDataAdapter(cmd);
//Create DataTable:
DataTable table = new DataTable("MyTable");
//fill table:
da.Fill(table);

//to show in your application there is many ways, one is to bind the table with a control (most common is the DataGridView control):
dataGridView1.DataSource = new BindingSource(table, null);
Mitja Bonca 557 Nearly a Posting Maven

This example requires that the code in the example is called from a form that has its IsMdiContainer property set to true.
That means that your MainForm has the property IsMdiContainer set to true;

//before creating a new instance of a Report class, do:
this.IsMdiContainer = true;
Report newMDIChile = new Report();
//and the rest of the code
Mitja Bonca 557 Nearly a Posting Maven

You will slowely starting to experiance what C# offers. You will be amazed what you can do with it (almost everything it comes up into yout mind).
Just remember: nothing is impossible.
Even if you hardly can imagine something in your mind, it sure is possible to put this into working code.

Enjoy... :)

Mitja Bonca 557 Nearly a Posting Maven

Yep
just to add to ddanbe post (how to practicaly do it):

string a = "10:12";
a = a.Replace(":", ".");
Mitja Bonca 557 Nearly a Posting Maven

Try using DataSource property to bind the data with the contorol:

Dim listofdays As New List(Of String)()
'populate the list
'then bind comboBox with the generic list<T>:
comboBox1.DataSource = listofdays
Mitja Bonca 557 Nearly a Posting Maven

YOu are welcome?

btw, if you are satisfied with the answer, you can mark it as answered (or vote up).
thx in advance

Mitja Bonca 557 Nearly a Posting Maven

You forgot to define a value in the String format:

Dim intValue As Integer = 12345
Dim strValue As String = [String].Format("{0:000000}", intValue)
'output is : 012345
Mitja Bonca 557 Nearly a Posting Maven

Do you know that this line of code:

string strSource = webClient.DownloadString(URL);

will get the whole code of the website. So its almost impossible to compare this text with some other.
You will have to get some text out of that string.

Mitja Bonca 557 Nearly a Posting Maven

Use Linq:

string[] a = { "a", "b", "c" };
string[] b = { "b", "c", "d" };
string[] c = a.Intersect(b).ToArray();

Array c has values "b" and "c".

Mitja Bonca 557 Nearly a Posting Maven

Momerath, I can see you are pretty familiar with Regex. But Iam not. I would like to learn then more.
So I will ask right here. How to do (seperate) the regex, that will check for more conditions?
Is the seperator the backslash '\'? Or how would be the easiest way to combine it?

Mitja Bonca 557 Nearly a Posting Maven

I would even suggest you to create you own report (recommend Crystal Reports) and pass data (checked rows) to the report and show then here.

Mitja Bonca 557 Nearly a Posting Maven

You want to convert some value to double, which apparently is NOT a double. So to get rid if try, catch blocks and some strnage errors, you can use TryParse method in this manner:

double answer;
            if (sender is System.Windows.Forms.Button)
            {
                if (double.TryParse(answerBox.Text, out answer))
                    answer = Convert.ToDouble(answerBox.Text);
                else
                    MessageBox.Show("inserted value \"" + answer + "\" is not a number (type double)!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
Mitja Bonca 557 Nearly a Posting Maven

Code like Sort() method is completely bound by how fast you can get the data off the disk. The file simply can never fit in the file system cache so you're always waiting on the disk to supply the data. You're doing fairly well at 10 MB/sec, optimizing the code is never going to have a discernible effect.

Get a faster disk. Defrag the one you've got as an intermediate step.
And its the fault of yout system if it hangs up. It shouldnt.

-------------------------------------------------

There is another solution:
Short answer - load the data into a relational database eg Sql Express, create an index, and use a cursor based solution eg DataReader to read each record off and write it to disk.

-------------------------------------------------

If this would help you out you go ahead and do your own custom sorting algoritm. For info you can go HERE. But remember, you have to be good at math ;)

Mitja Bonca 557 Nearly a Posting Maven

If there is really alot of data, which will be a time consuming action, you can create a new thread (or use BackGroundWorker, which is a new thread too), and use Sort method:

string [] array = {"some values in array"};
Array.Sort(array);
Mitja Bonca 557 Nearly a Posting Maven

According to MSDN :

Setting the BackColor has no effect on the appearance of the DateTimePicker.

You need to write a custom control that extends DateTimePicker. Override the BackColor property and the WndProc method.

Whenever you change the BackColor, don't forget to call the myDTPicker.Invalidate() method. This will force the control to redrawn using the new color specified.

const int WM_ERASEBKGND = 0x14;
protected override void WndProc(ref System.Windows.Forms.Message m)
{
     if(m.Msg == WM_ERASEBKGND)
     {
       Graphics g = Graphics.FromHdc(m.WParam);
       g.FillRectangle(new SolidBrush(_backColor), ClientRectangle);
       g.Dispose();
       return;
     }

     base.WndProc(ref m);
}

Here is another example of chnaging backColor to dtp: http://www.codeproject.com/KB/selection/DateTimePicker_With_BackC.aspx

Mitja Bonca 557 Nearly a Posting Maven

Disable all the controls (set the property of each control "Enabled" to false).
Then when user inserts his userName and password validate the data, if all coorect, enable all the controls.

Mitja Bonca 557 Nearly a Posting Maven

Glad to hear.
btw... if you are (partly) satisfied with the answer or you get any good idea from the post, you can up vote the post, or mark the thread as answered (so we close it up). Any anyone else who faces these kind of issues gets the solution earlier.
Thx in advance.

Mitja Bonca 557 Nearly a Posting Maven

Enabled property means that the control is accessabled (if set to true). If set to false its not in use (its like readonly).
try it.

Mitja Bonca 557 Nearly a Posting Maven

use Enable property (not ReadOnly):

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            textBox1.Enabled = false;
            textBox1.Text = "Some text";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Enabled = true;
            textBox1.Focus();
            textBox1.SelectionStart = 0;
            textBox1.SelectionLength = 0;
        }
    }
Mitja Bonca 557 Nearly a Posting Maven

If you would like to validate the last part of the email string; this are the extensions (com, us, ...) i would suggest you to do a list of them, and then loop through them to check if the inserted one has any match, like here:

/// <summary>
/// method for determining is the user provided a valid email address
/// We use regular expressions in this check, as it is a more thorough
/// way of checking the address provided
/// </summary>
/// <param name="email">email address to validate</param>
/// <returns>true is valid, false if not valid</returns>
public bool IsValidEmail(string email)
{
    //regular expression pattern for valid email
    //addresses, allows for the following domains:
    //com,edu,info,gov,int,mil,net,org,biz,name,museum,coop,aero,pro,tv
    string pattern = @"^[-a-zA-Z0-9][-.a-zA-Z0-9]*@[-.a-zA-Z0-9]+(\.[-.a-zA-Z0-9]+)*\.
    (com|edu|info|gov|int|mil|net|org|biz|name|museum|coop|aero|pro|tv|[a-zA-Z]{2})$";
    //Regular expression object
    Regex check = new Regex(pattern,RegexOptions.IgnorePatternWhitespace);
    //boolean variable to return to calling method
    bool valid = false;

    //make sure an email address was provided
    if (string.IsNullOrEmpty(email))
    {
        valid = false;
    }
    else
    {
        //use IsMatch to validate the address
        valid = check.IsMatch(email);
    }
    //return the value to the calling method
    return valid;
}
Mitja Bonca 557 Nearly a Posting Maven

So you would like to create a sql Query?

Mitja Bonca 557 Nearly a Posting Maven

Try this code:

public static bool isValidEmail(string inputEmail)
{
   string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
         @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" + 
         @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
   Regex re = new Regex(strRegex);
   if (re.IsMatch(inputEmail))
    return (true);
   else
    return (false);
}
Mitja Bonca 557 Nearly a Posting Maven

The easiest way would be to get all and then count top 6 from the dataTable.

//create connection, command (cmd)
DataTable table = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(table);

//select top 6:
//you can even sort datra if you want!!
for(int i = 0; i < table.Rows.Count; i++)
{
   if(i < 6)
   {
        //show data where ever...
   }
   else
        break;
}
Mitja Bonca 557 Nearly a Posting Maven

Hi, if you have dgv bound to dataTable you can only loop through the dataTable, and retreive all the data from dataTable (no need from dgv), because all the data put into dgv, are "automatically" saved into dataTable as well (because of the binding source).

1st loop has to go by looping through the rows, and 2nd one has to loop through the columns:

for (int i = 0; i < table.Rows.Count; i++)
            {
                for (int j = 0; j < table.Columns.Count; j++)
                {
                    DateTime dt1 = Convert.ToDateTime(table.Rows[i][j]).AddDays(1);
                    if (DateTime.Now > dt1)
                    {
                        string sta = "Pending";
                        SqlCommand cmd3 = new SqlCommand("UPDATE tblDaily_Task_Schedule SET Task_Status = '" + sta + "'", con);
                        cmd3.ExecuteNonQuery();
                    }
                }
            }
Mitja Bonca 557 Nearly a Posting Maven

Are you talking about connection string?
If so you can insert values of the textBoxes into conn.string like this:

string = @"Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=" + textBoxUsername.Text + ";Password=" + textBoxPassword.Text + ";";
Mitja Bonca 557 Nearly a Posting Maven
static void Main(string[] args)
        {
            Program d = new Program();
            d.Myprog("ahasda");
            Console.ReadLine();
        }
        void Myprog(params string[] array)
        {
            int num = 0;

            foreach (string str in array)
            {
                foreach (char c in str)
                {
                    if (c.Equals('a'))
                        num++;
                }
            }
            Console.WriteLine(num);
        }
Mitja Bonca 557 Nearly a Posting Maven

I did a whole example with one question and 3 answers.
Take a look at here:

Random r = new Random();
        string correctAnswer;
        public Form1()
        {
            InitializeComponent();
            label1.Text = "";
            RadioButton[] rbs = { radioButton1, radioButton2, radioButton3 };
            foreach (RadioButton rb in rbs)
                rb.CheckedChanged += new EventHandler(rb_CheckedChanged);
            DeselectAll(false);
        }

        private void DeselectAll(bool bShow)
        {
            RadioButton[] rbs = { radioButton1, radioButton2, radioButton3 };
            foreach (RadioButton rb in rbs)
            {
                if (bShow)
                    rb.Visible = true;
                else
                    rb.Visible = false;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DeselectAll(true);

            //this code bellow is only an example of question and answers. 
            //you need to do your own code of question
            
            label1.Text = "Which is the 3rd planet from the sun?";
            string[] answers = new string[] { "Mars", "Jupiter", "Earth" };
            correctAnswer = "Earth";
            string[] randomAnswers = answers.OrderBy(o => r.Next()).ToArray();
            radioButton1.Text = randomAnswers[0];
            radioButton2.Text = randomAnswers[1];
            radioButton3.Text = randomAnswers[2];
        }

        private void rb_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton rb = sender as RadioButton;
            if (rb.Checked)
            {
                string selectedAnswer = rb.Text;
                if (selectedAnswer.Equals(correctAnswer))
                    MessageBox.Show("Answer is correct.");
                else
                    MessageBox.Show("Answer is wrong!");
            }
        }
Mitja Bonca 557 Nearly a Posting Maven

Here you go:

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

        private void button1_Click(object sender, EventArgs e)
        {
            DeselectAll();
            string[] answers = new string[] { "Mars", "Jupiter", "Earth" };
            string[] randomAnswers = answers.OrderBy(o => r.Next()).ToArray();
            radioButton1.Text = randomAnswers[0];
            radioButton2.Text = randomAnswers[1];
            radioButton3.Text = randomAnswers[2];
        }
Mitja Bonca 557 Nearly a Posting Maven

what was is? It was yout sql query? Was not ok before?

Mitja Bonca 557 Nearly a Posting Maven

Or:

string example = "0123456789";
int count = example.Length;
Mitja Bonca 557 Nearly a Posting Maven

That means that your DataTable is empty. You didnt get any data out of the dataBase. Check the sql query.

Mitja Bonca 557 Nearly a Posting Maven

You have to specify the full path in the connection string, like on this example:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyFolder\MyDatabase.mdb;User Id=admin;Password=;

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.

Mitja Bonca 557 Nearly a Posting Maven

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

Mitja Bonca 557 Nearly a Posting Maven

You can bind it (this is the best solution and th fastest).

dataGridView1.DataSource = new BindingSource(myDataSet.Tables["tableName"], null);

Thats it!
And the data will appear in the DGV.

Mitja Bonca 557 Nearly a Posting Maven

Hi, would you show me the code you have there?

Mitja Bonca 557 Nearly a Posting Maven

To add:

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 EvenHandler(NewGame_Click);           
                        this.Controls.Add(NewGame);
                 }

                 private void NewGame_Click(object sender, EventArgs e)
                 {
                       //do the code on the button click here
                 }
            }
      }
}
Mitja Bonca 557 Nearly a Posting Maven

Sorry, but i really dont understand a think what you are saying. What regedit? Can you please show the picture or something, or do a better explanation. I really cant get the point out of this statement you just posted.
best regards,

Mitja Bonca 557 Nearly a Posting Maven

abelLazem showed you on the picture where to look for Designer class of the Form.
If you havent delete the whole form class, it shoud be there.

Mitja Bonca 557 Nearly a Posting Maven

Actually I'm make a system in C# but this system want link to old system(vb). So that I'm just add the data into old system database. I'm found that have RecNo. So I'm not choice, must be follow old system database. because some other system also follow this. Because this part of system is use to arrange Lorry can take how many thing.

Anyway, you can still use code i gave you, just a bit modified.

Tell me something, how do you know when you need a new Record number, because of this depends what to look 1st.

Mitja Bonca 557 Nearly a Posting Maven

What dont you put all the data into DataTable, and then only use SqlCommandBuilder object to do an Update of the data in DataTable to the Appropriate Table in DataBase?

Here are links how to do it:
http://support.microsoft.com/kb/308507 and
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.updatecommand%28v=vs.71%29.aspx

Mitja Bonca 557 Nearly a Posting Maven

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.

Mitja Bonca 557 Nearly a Posting Maven

One thing, I would strongly suggest you to use only one column for the record number.
You have to combine Loading number and Record number. This way you will have a lot less problems.
It sure is possible to create a working code for this kind of dataBase structure you have now, but I repeat my self, if there is no condition to have borh columns, remove one, and have only one.
Anfd there is still one thing missing in the Loading number: a year value. What if the year changes to the next one? You will get duplicates for sure.

Your record number shoud look like "dd/MM/yyyy/record number (4 digits)
So you will run records by date and the record number:
4/5/2011/0001
4/5/2011/0002
4/5/2011/0003
5/5/2011/0001
and so on!!

Isnt this a better, any most important, way simplier idea?

If you answered with yes, you can take a look into my code example, which does this work:

class Program
    {
        private static string connString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=D:\AppsTest\2011\Apr15DB_AutoGenerate\monthAutoGenerateID.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
        static void Main(string[] args)
        {
            //get this month`s name:
            DateTime date = DateTime.Now;
            string month3Letters = String.Format("{0:MMM}", date);

            //get last id from dataBase:
            string newID = GetLastID();
            if (newID != null)
            {
                string onlyMonthName = newID.Substring(0, 3);
                if (onlyMonthName == month3Letters)
                {
                    //get number from id:
                    int numberID = Convert.ToInt32(newID.Remove(0, 3));
                    //auto-increment to get new id:
                    numberID++;
                    //now we have to add zeros on the left side …
ddanbe commented: Continous effort. :) +14
Mitja Bonca 557 Nearly a Posting Maven

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:

int filesSelected = listBox1.SelectedIndices.Count;
Mitja Bonca 557 Nearly a Posting Maven

Hi,
Im glad you found the source of the problem.
About your last question:

cmbCourses.DataSource = table;  //what is table in this sentex?

You are saying that you have a DataSet, which must have at least on DataTable (table is the variable name), so it could be this way:

cmbCourses.DataSource = yourDataSet.Tables["tableName"];  //instead of tableName, you can specify the table index, like [0] - thats the 1st table in the dataSet.