Mitja Bonca 557 Nearly a Posting Maven

If I understand you, you would like to remember the X,Y position of the windows form.
So when the form is re-opened, it has to appear on the same spot as it was last time, righ?

If so, here is an exmaple how to get the points and insert them into DB:

private void SavingCoordinatesIntoDB()
        {
            int[] XY = GetFormCoordinates();
            using (SqlConnection sqlConn = new SqlConnection("yourConnectionString"))
            {
                string insertString = "INSERT INTO .... VALUES(@x, @y)";
                using (SqlComand cmd = new SqlCommand(insertString, sqlConn))
                {
                    cmd.Parameters.Add("@x", SqlDbType.Int).Value = XY[0];
                    cmd.Parameters.Add("@y", SqlDbType.Int).Value = XY[1];
                    sqlConn.Open();
                    cmd.ExecuteNonQuery();
                    sqlConn.Close();
                    //you can put upper line into try, catch statement, to capture the errors (if any occures).
                }
            }
        }


        private int[] GetFormCoordinates()
        {
            int deskWidth = Screen.PrimaryScreen.Bounds.Width;
            int deskHeight = Screen.PrimaryScreen.Bounds.Height;

            int appWidth = this.Width;
            int appHeight = this.Height;

            int spX = (deskWidth - appWidth) / 2;
            int spY = (deskHeight - appHeight) / 2;

            return new int[] { spX, spY };
        }

Hope it helps, and this is what you meant. If now, let me know, I`ll try to help you...
bye
Mitja
Mitja Bonca 557 Nearly a Posting Maven

If you want to send SMS from PC, this will not be free. You will have to pay for it. It was free a few years back, but not its payable stuff.
Anyway, here you can find some help:
http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/3b5a4fc8-b8f0-4663-b7fd-b04f0a3e4bd3
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/278219a1-20e8-4d25-a2ed-eafbe7ef0bb1

I was creating a software which was used to support sending sms, it worked fine, but its not for free. So I let it go. I did and still works similar email sending.
Why dont you consider this. Everyone uses email these days.

If you still want to create sending sms, please go here: http://www.smsmail.com/
This is a webiste, where you can buy credits to send sms.

Best of luck,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Here is a simple example of how to populate listView. I have put all together into one method, but its better to put the column creations into form load (so it loads only one time).
This is the code:

private void PopulatingListView()
        {
            this.listView1.Items.Clear();

            this.listView1.Columns.Add("1st column", 75, HorizontalAlignment.Left);
            this.listView1.Columns.Add("2nd column", 75, HorizontalAlignment.Left);
            this.listView1.Columns.Add("3rd column", 75, HorizontalAlignment.Left);
            this.listView1.View = View.Details;
            this.listView1.FullRowSelect = true;

            int[] array1 = new int[] { 1, 2, 3, 4, 5 };
            string[] array2 = new string[] { "A", "B", "B", "D", "E" };
            string[] array3 = new string[] { "A1", "B2", "C3", "D4", "E5" };

            for (int i = 0; i < 5; i++)
            {
                ListViewItem lvi = new ListViewItem(array1[i].ToString());
                lvi.SubItems.Add(array2[i]);
                lvi.SubItems.Add(array3[i]);
                this.listView1.Items.Add(lvi);
            }
        }
Mitja Bonca 557 Nearly a Posting Maven

What happens? Nothing. It will not set it! Thats why its better to avoid such coding (as I explained up there). Its better to use code, and let user know that the (in your example) id is not long enough.

Im glad I can help,
bye
Mitja

Mitja Bonca 557 Nearly a Posting Maven

This was not a question, I know how to do a set method that can do a comparation, but in my opinion its better to use methods for these kind of actions.

Mitja Bonca 557 Nearly a Posting Maven

if (textbox1.Text == 6) // this is to check if the string input is equal to 6 chars.
{
your code here
}
else
{
MessageBox.Show("The data you input is not valid or less than expected)
}

if you want to set only 6 digits
then..

private void studentID;
public int StudentID
{
get { return detailsID; }
set
{
if (studentID == 6)
{
studentID = value;
}
}

this will definetely help you!

this will defenately NOT help you!
What you have stated is completely wrong! Please do not reply with such answers.

1. If you want to check the lenght of the string, so how many characters string has you have to do with string.Lengt property, and not with equalizing to the number, like you did (string == 6) - COMPLETELY WRONG; What you did its only comparing if the string has number 6, nothing else.

2.Your set method is again completely wrong. How the hack do you compare if the sting has 6 characters?
btw, do you know what it means 6 characters? This is not a string "6", but its a string that consists 6 different letters, number or signs (12ab,.) - that means 6 characters long.

Anyway, as I said, Get,Set method is not meant to do any checking (even if its possible to do it), but it`s meaning shows it`s …

nssltd commented: I dont see whats wrong with this post it is correct! +1
Mitja Bonca 557 Nearly a Posting Maven

This is an example where is shown everything you need. I did it only for you:
... I hope you like it, note: do a copy/paste to CONSOLE application, and try to run it!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Okt17GetSet
{
    class Program
    {
        List<StudentInfo> studentList = new List<StudentInfo>();

        static void Main(string[] args)
        {
            bool bChecking = false;
            Program pro = new Program();
            Console.WriteLine("Hi there,");
            while (!bChecking)
            {
                Console.WriteLine("Do you want to ADD new or SEARCH for the student?");
                Console.WriteLine("(1 - add, 2 - search, 3 - exit program)");
                string strQuestion = Console.ReadLine();
                if (strQuestion != null)
                {
                    if (strQuestion == "1")
                        pro.AddingStudent();
                    else if (strQuestion == "2")
                        pro.GettingStudent();
                    else if (strQuestion == "3")
                        bChecking = true;
                    else
                    {
                        Console.WriteLine("Wrong answer, please do it again...");
                        continue;
                    }
                }
            }
            Console.WriteLine("bye, bye...");
            System.Threading.Thread.Sleep(1000);
            Environment.Exit(0);
        }

        private void AddingStudent()
        {
            bool bChecking = false;
            string strID = null;
            string strName = null;

            while (!bChecking)
            {
                Console.WriteLine("Please, insert students ID:");
                strID = Console.ReadLine();
                if (strID.Length >= 6)
                {
                    while (!bChecking)
                    {
                        Console.WriteLine("Please insert student`s name:");
                        strName = Console.ReadLine();
                        if (strName.Contains(" "))
                            bChecking = true;
                        else
                            Console.WriteLine("Student needs to have name and last name...");
                    }
                }
                else
                {
                    Console.WriteLine("Student`s ID is not long enough, it must be at least 6 characters...");
                }
            }
            //when all ok, do an insertion into list of students:
            //1. ADDING NEW STUDENT:
            StudentInfo info = new StudentInfo();
            info.StudentID = strID;
            info.Name = strName;
            studentList.Add(info);

            Console.WriteLine("New student data saved into list!");
            Console.WriteLine("ID: {0}, NAME: …
ddanbe commented: Nice effort. +8
Mitja Bonca 557 Nearly a Posting Maven

Check this out, and let me know if its helps:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Okt17GetSet
{
    class Program
    {
        List<StudentInfo> studentList = new List<StudentInfo>();

        static void Main(string[] args)
        {
            
            Program pro = new Program();
            pro.GettingStudents();
        }

        private void GettingStudents()
        {
            bool bChecking = false;
            string strID = null;
            string strName = null;

            while (!bChecking)
            {
                Console.WriteLine("Please, insert students ID:");
                strID = Console.ReadLine();
                if (strID.Length >= 6)
                {
                    while (!bChecking)
                    {
                        Console.WriteLine("Please insert student`s name:");
                        strName = Console.ReadLine();
                        if (strName.Contains(" "))
                            bChecking = true;
                        else
                            Console.WriteLine("Student needs to have name and last name...");
                    }
                }
                else
                {
                    Console.WriteLine("Student`s ID is not long enough, it must be at least 6 characters...");
                }
            }
            //when all ok, do an insertion into list of students:
            StudentInfo info = new StudentInfo();
            info.StudentID = strID;
            info.Name = strName;
            studentList.Add(info);

            Console.WriteLine("New student data saved into list!");
            Console.WriteLine("ID: {0}, NAME: {1}", strID, strName);
            Console.ReadLine();
        }
    }

    public class StudentInfo
    {
        private string studentID;
        private string name;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        public string StudentID
        {
            get { return studentID; }
            set { studentID = value; }
        }
    }
}
Mitja Bonca 557 Nearly a Posting Maven

Just take it easy, get some book that you will get the basic knowledge. Even the internet has a lot of example code, but start with simple things, and do not let your self to get invalved into some serious and demanding project - at least not in the beginning (this usually takes from 1 -2 years).

Mitja Bonca 557 Nearly a Posting Maven

Hi, and welcome to programming...
If you are creating WinForms App or some other, 1st you create GUI, then you start creating the code, using the Controls (and their methods) putted onto the GUI.
This is for the beginnng.
When you will become a bit more advanced, you can create Controls and their methods by the code (You do not need to put them on the form - becuase when you manually put some control, lets say a TextBox on the form, C# automatically creates the code for it. Take a look into YourForm.Designer.cs file for the code).


Manual creation of the control and it`s method:

//CALL THIS METHOD IN FORM LOAD (OR SOMEWHERE BEFORE YOU INTEND TO USE THE TEXTBOX):
        private void CreatingNewTextBox()
        {
            TextBox textBox1 = new TextBox();
            textBox1.Name = "textBox1";
            textBox1.Size = new Size(100, 20);
            textBox1.Location = new Point(20, 20);
            this.Controls.Add(textBox1);
            textBox1.TextChanged += new EventHandler(textBox1_Click);
        }

        //CREATE NEW METOHD FOR TEXTBOX (THIS IS AN EXAMPLE, THERE IS PLENTY OF METHODS AVAILABLE):
        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
Mitja Bonca 557 Nearly a Posting Maven
shibin09 commented: thanx +0
Mitja Bonca 557 Nearly a Posting Maven
string[] sections = line.Split(new char[] {"><"}, StringSplitOptions.RemoveEmptyEntries);