Mitja Bonca 557 Nearly a Posting Maven

I have done some homework for you, and this is the code I came up with. There is still some work to be done with selecting folder, now you have to write paths, but this is not the thread of this thread. Mainly the app works like you wanted to (I hope).

On the form put these controls:
- textBox (for inseting path to the folders)
- comboBox (to select files - text files)
- richTextBox (where text is displayed)
- button (to save the changed file)

optional:
- labels over controls to specify what they are/do

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections.ObjectModel;

namespace Nov26EditFiles
{
    public partial class Form1 : Form
    {
        string folderPath;
        string fileName;
        int textLenght;
        bool bSaved;
        bool bJumpCode;

        public Form1()
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
            this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
        }

        private void PopulatingComboBox()
        {
            try
            {
                this.comboBox1.Items.Clear();
                this.richTextBox1.Text = null;
                string[] allFilesPath = System.IO.Directory.GetFiles(@"" + folderPath, "*.txt");//, System.IO.SearchOption.AllDirectories);
                foreach (string filePath in allFilesPath)
                {
                    string file = System.IO.Path.GetFileName(filePath);
                    this.comboBox1.Items.Add(file);
                }
                int filesCount = allFilesPath.Length;
                MessageBox.Show(filesCount + " files found in:\n" + folderPath, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch
            {
                MessageBox.Show("The written path is not valid.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!bJumpCode)
            {
                try
                {
                    string fileName2 = this.comboBox1.SelectedItem.ToString();
                    int textLenghtNew = this.richTextBox1.Text.Length;

                    if (!bSaved && textLenghtNew != textLenght)
                    {
                        if (DialogResult.Yes == MessageBox.Show("File " + fileName + " has …
Mitja Bonca 557 Nearly a Posting Maven

YOu can alse try:

if(!String.IsNullOrEmpty(textBox1.Text))
{
   //is its not null and not empty!
}
Mitja Bonca 557 Nearly a Posting Maven

PS: ok some understanding from me and some help for you, that will be a bit easier to explain:
you have a dgv. With columns.
- What exactly are these columns?
- What exactly are the data in these columns?
- What would be the file like (whihch type - txt?) to write into and read from it?
- How and when the dgv needs to be populated (and refreshed - if ever)?
- and some your important info

bye,

Mitja

Mitja Bonca 557 Nearly a Posting Maven

Can you be please a bit more splecific. What exactly do you need.
And the code above you`ve posted, its not in any help - it has nothing to do with your question. So please concentrate on what you need, and if you want some help from us, please, explain your needs (precisly).
Because now I can only guess and do 1000 of lines of code only for your and on the end will all be worthless. I hope you understand, so please do your best.
bye,

Mitja

Mitja Bonca 557 Nearly a Posting Maven

If you mean that you have a file on a hdd, and you want to read out from it, then like this:

private static void ExerciseMethod()
        {
            System.Collections.ArrayList list = new System.Collections.ArrayList();
            using (System.IO.StreamReader sr = new System.IO.StreamReader(@"C:\1\FileExample.txt"))
            {
                string line = null;
                while ((line = sr.ReadLine()) != null)
                {
                    string[] array = line.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries);
                    list.Add(array[1].Trim());
                }
            }
            for (int i = 0; i < list.Count; i++)
            {
                string value = list[i].ToString();                
                this.comboBox1.Items.Add(value);
            }
        }

Hope this help you.

Mitja Bonca 557 Nearly a Posting Maven

You would like to insert some data to Database, from DataSet, am i correct?
Can i see the code which creates and populates the dataSet?

Mitja Bonca 557 Nearly a Posting Maven

What do you have on the forms you would like to change (shrink or grow)? Controls? Which one? I this the only way to accomplish what you want is , that on every scroll of the mouse, you would have to recalculate and reposition all the controls (all the stuff) on the form. But this is not so tuff I would say. You have to dfine for how much one mouse scroll is going to be (in inches) so then for example:

NOW:
textBox1:
- Location = 100,200
- Size = 100, 23
- Text size = 10
- ...

You want to shrink it (one scroll of a mouse) by 10 inches:
You have to set new parameters for the textBox:
- Location: 90, 90
- Size: 90, 23
- TextSize 10

but you also have to consider that if you scroll the wheel by 10 times the X and Y axes can come to 0, if 11 times, it will be even -10. But you dont want to have it.
So some if/esle statemets will be needed as well.

For sure there is pretty much of work, depending on how many things (controls) you have on each form.
But there is no other way, I would say (at least not easier).
So, happy coding, and good luck.

But I˙m still interesting to know, what kind of controls you have on each form.
bye,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

sure,
AND = &&
OR = ||
So you can write it like:

if(textBox1.Text != "" && textBox2.Text != "")
{
    //is both are empty, code will go in here
}
if(textBox1.Text != "" || textBox2.Text != "")
{
    //is any of textoxes is empty, code will go in here
}
Mitja Bonca 557 Nearly a Posting Maven
Mitja Bonca 557 Nearly a Posting Maven

You populate listView on clicking on a button, if I understand you well. So no need to use a listView even to do something with the data from it. Simply create another method for calculations which will be called just after listView population, and it will look something like it:

private void button1_Click(object sender, EventArgs e)
{
    ListViewPopulating();
    Calculations();
}

private void ListViewPopulating()
{
    string a = textBox1.Text;
    string b = textBox2.Text;
    //and so on
    //and listView actual population
}

private void Calculations()
{
    for (int i = 0; i < listView1.Items.Count; i++) //row by row!
    {
         string a1 = listView1.Items[i].Text; //value in 1st column
         string a2 = listView1.Items[i].SubItems[1].Text; //value in 2nd column
         //and so on...
         //this is how you retrive the values from listView, and use them to do the calculations!
    }
}

If there is anything you would like to know, please go ahead and ask.
bye,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Here is the code I did only for you. Hope it helps.
In case if yout app. is made to accect more then one user, this one will not work. Let me know, I will change to for you only!

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;   //IN SOLUTION EXPLORER CLICK ON REFERENCES, AND CHOOSE ADD REFERENCE - CHOOSE SYSTEM.CONFIGURATION!

namespace Nov25Exercise
{
    public partial class Form1 : Form
    {
        string userName;
        List<LoggedUsers> listUsers;
        public Form1()
        {
            InitializeComponent();
            this.AcceptButton = this.buttonLogin;
            this.StartPosition = FormStartPosition.CenterScreen;
            listUsers = new List<LoggedUsers>();
        }

        protected override void OnShown(EventArgs e)
        {
            this.buttonLogout.Visible = false;
            base.OnShown(e);
        }

        private void buttonLogin_Click(object sender, EventArgs e)
        {
            string newUser = this.textBoxUserName.Text.Trim();
            if (!String.IsNullOrEmpty(newUser))
            {
                //check for the correct login!
                bool bCheckingLogin = DAL.CheckingUserExistance(newUser);
                if (bCheckingLogin)
                {
                    userName = newUser;
                    NewUserLogin(userName);
                    MessageBox.Show(userName + " has successfully logged in.");
                }
                else
                    MessageBox.Show("The user name does not exist in the database.\nPlease try to login again...");
                //setting the form to suit the needs:
                ChangingForm(bCheckingLogin);
            }
            else
            {
                MessageBox.Show("Please enter your user name.");
                this.textBoxUserName.Focus();
            }
        }

        private void buttonLogout_Click(object sender, EventArgs e)
        {
            DateTime logoutTime = DateTime.Now;
            DAL.UserLoginLogout(false, userName, new DateTime(1900, 1, 1), logoutTime);

            //erasing the user from the list:
            UsersLogout();
            //changing the form to starting state:
            ChangingForm(false);
        }

        private void NewUserLogin(string userName)
        {
            LoggedUsers logged = new LoggedUsers();
            logged.userName = userName;
            logged.loginTime = DateTime.Now;
            logged.logoutTime = new DateTime(1900, 1, 1);
            //when doing a login - logout will be set …
Mitja Bonca 557 Nearly a Posting Maven

One more thing: How many users can login to the aplication?
Only one, or more? This is very important.

Beucase if there will be more users logged in, things become a bit more complicated.

Mitja Bonca 557 Nearly a Posting Maven

But this is not a slolution he is looking for. He uses a DataBase, not a file.
I`ll try to do the code for you. Wait a bit...

EDIT: I would like to know which data type are column login and logout? Are type of DataTime? Or something else?
Its important, becuase if they are DateTime, the value inserted cannot be null (DateTime cannot be null, it always needs to have a value).

later

Mitja Bonca 557 Nearly a Posting Maven

or if you would like to have the string written in two (2) rows:

private static OleDbCommand DbConnect(OleDbCommand mDB)
        {
            mDB.ConnectionString = @"Provider = Microsoft.Jet.OLEDB.4.0; " +
                                   @"Data source= C:\Database\winbase.mdb";
            return mDB;
        }
Mitja Bonca 557 Nearly a Posting Maven

Write the string as follows:

private static OleDbCommand DbConnect(OleDbCommand mDB)
        {
            mDB.ConnectionString = @"Provider = Microsoft.Jet.OLEDB.4.0; Data source= C:\Database\winbase.mdb";
            return mDB;
        }
This should work!
Mitja Bonca 557 Nearly a Posting Maven

For example how "Hello World" change to "H e l l o W o r l d":

string value = "Hello World";
char[] letters = value.ToCharArray();
string newValue = null;
foreach(char letter in letters)
{
   newValue += letter + " ";
}
MessageBox.Show(newValue);
Mitja Bonca 557 Nearly a Posting Maven

I dont really understand you what you want now. What is exactly you are traing to achive?
Would you like from string "Hello World", change it to "H e l l o W o r l d"?

And what concerns your 1st question in your 1st post, YES, you are allowed to split nothing. If you have in mind example "thisIsTestString" - here is no white spaces, so code wont split - but there will still be NO error. There will be 1 array (same as 1 string), in a word - wortheless to have an array, but as said, no error - so you are allowed to split.

Mitja Bonca 557 Nearly a Posting Maven

I will show you a sime example of to split array. Here you go:
//this is a button1_Click method, or could be even anything else:

string value = textBox1.Text;
if(value.Lenght > 0)
{
     string[] array = value.Split(' '); //split by whitespace
     string rows = null;
     int i = 0;
     while ( i < array.Lenght)
     {
           rows += array[i] + Environment.NewLine;
           i++;
     }
     MesssageBox.Show("The mesage:\n" + + rows + "was split into " + array.Lenght.ToString() + " parts.");
}

Hope this helps you to understand the "split" method, using whitespace as splitter.
Mitja
Mitja Bonca 557 Nearly a Posting Maven

This code is incomplete, as is the project you have found on the codeprocejct.com.
There is missinf main() method and some parameters.

This is the 1st method which can be called from the Main() method:

public static void FullScanPageCode39(ArrayList CodesRead, Bitmap bmp, int numscans){}
Mitja Bonca 557 Nearly a Posting Maven

DaveTran: I really dont understand what can be wrong with your original loop.
How long is the "batchVerticles object? it is less then 3? I dont know what you have "optimized" it in the way you did - thats not optimization. Its de-optimization.

Can you please explain bit better, why you dont use your 1st original loop. It doesnt make sence to me (yet).

Mitja Bonca 557 Nearly a Posting Maven

This code has got to do, what you have asked in the 1st post of the thread:

public partial class Form1 : Form
    {
        bool bJump;
        public Form1()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (!bJump)
            {
                int intValue = 0;
                string strValue = textBox1.Text;
                bool bChecking = int.TryParse(strValue, out intValue);
                if (!bChecking && strValue != "")
                {
                    strValue = strValue.Remove(strValue.Length - 1, 1);
                    bJump = true;
                }
                textBox1.Text = strValue;
                textBox1.SelectionStart = textBox1.Text.Length;
            }
            else
                bJump = false;
        }
    }
Mitja Bonca 557 Nearly a Posting Maven

Here you have an example of how to upload an image to a database.
And btw, you dont need to savew the file path to a database table (its useless):
http://www.aspfree.com/c/a/ASP.NET/Uploading-Images-to-a-Database--C---Part-I/
http://www.daniweb.com/forums/thread273361.html

Mitja Bonca 557 Nearly a Posting Maven

I changed a bit your code, but I dont know what "ReadCode" on line 26 from the code bellow, would be. So I couldnt test it:

static void Main(string[] args)
        {
            ArrayList list = new ArrayList();
            list.Add("Test1");
            list.Add("Test2");
            Bitmap bmp = new Bitmap(@"C:\myTestPic.jpg", true);
            int numScans = 2;
            FullScanPageCode39(list, bmp, numScans);
        }

        public static void FullScanPageCode39(ArrayList CodesRead, Bitmap bmp, int numscans)
        {
            for (int i = 0; i < 4; i++)
            {
                bmp.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone);
                VScanPageCode39(CodesRead, bmp, numscans);
            }
        }

        public static void VScanPageCode39(ArrayList CodesRead, Bitmap bmp, int numscans)
        {
            string read;
            bool test;
            for (int i = 0; i < numscans; i++)
            {
                read = ReadCode39(bmp, i * (bmp.Height / numscans), (i * (bmp.Height / numscans)) + (bmp.Height / numscans));

                test = false;
                foreach (object tester in CodesRead)
                {
                    if ((tester.ToString() == read) || (read.Trim() == "")) test = true;
                }
                if (!(test)) CodesRead.Add(read);
            }
        }
Mitja Bonca 557 Nearly a Posting Maven

1st of all, why do you use button DoubleClick event? Why not only Click?
2nd of all, I dont understand you what exactly is going on (wrong). So can you please upload some of the code, which you suspect has the issue?
thx
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Great, I am glad you put it into work (code I mean).
If there is anything else you would like to know, justask, I`ll e glad to help you out.

Mitja Bonca 557 Nearly a Posting Maven

I`ve done in 7 what? :)

Mitja Bonca 557 Nearly a Posting Maven

The code that I will post now, its one hell of a code. I just did it for my 1st time. And its works perfectly. I took me an hours to do it all.
I did as you wanted. On pre-installed button, the code created new buttons (one under another - if you want to position them manally, some changes need to be made for button.Location, but this is simple).
And when clicking on created buttons, you can do what ever you want with the code.

public partial class Form1 : Form
    {
        List<Button> listButtons;
        public Form1()
        {
            InitializeComponent();
            listButtons = new List<Button>();
        }

          private void buttonA_Click(object sender, EventArgs e)
        {
            int sizeX = this.buttonA.Width;
            int sizeY = this.buttonA.Height;
            int locationX = this.buttonA.Location.X;
            int locationY = this.buttonA.Location.Y;
            int i = listButtons.Count;
            foreach (Button _button in listButtons)
            {
                locationY = _button.Location.Y;
            }

            Button button = new Button();
            button.Name = "button" + (i + 1).ToString();
            button.Text = "button" + (i + 1).ToString();
            button.Location = new Point(locationX, (locationY + 30));
            button.Size = new Size(sizeX, sizeY);
            button.Click += new EventHandler(button_Click);
            button.Tag = i + 1;
            this.Controls.Add(button);
            listButtons.Add(button);
        }

         private void button_Click(object sender, EventArgs e)
         {
            int all = listButtons.Count;
            for (int i = 0; i < listButtons.Count; i++)
            {
                Button buttn = sender as Button;
                int index = (int)buttn.Tag;

                //
                //you can choose of 2 types of code (choose one, erase the other option):
                //

                //1: common code:
                if (index == (i+1))
                {
                    //here is a common code for all the …
Mitja Bonca 557 Nearly a Posting Maven

back to topic question:

//constructor:
        public Form1()
        {
            this.button1.Visible = false;
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (this.checkBox1.Checked)
                this.button1.Visible = true;
            else
                this.button1.Visible = false;
        }
Mitja Bonca 557 Nearly a Posting Maven

This is simple (again :))
You can use StreamReader to retrive data from file back to listView. This is how:

private void ReadingFromFile()
        {            
            using (StreamReader sr = new StreamReader(@"C:\2\testFile2.txt"))
            {
                while (!sr.EndOfStream)
                {
                    string line = sr.ReadLine();
                    string[] array = line.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    ListViewItem lvi = new ListViewItem(array[0].ToString());
                    lvi.SubItems.Add(array[1]);
                    this.listView1.Items.Add(lvi);
                }
            }
        }
Mitja Bonca 557 Nearly a Posting Maven
Mitja Bonca 557 Nearly a Posting Maven

I have a question.

I have a listbox. In it is a list of cars, and another listbox has a list of customers.

On another form, I have combox boxes. How do I write the data from the list boxes into the combo boxes, so that whatever data is in the listboes will display in the combo boxes?

Here is your solution:

//FORM1:
 public partial class Form1 : Form
    {
        Form2 form2;
        List<string> list;

        public Form1()
        {
            InitializeComponent();
            form2 = new Form2();
            list = new List<string>();
        }


        private void button1_Click(object sender, EventArgs e)
        {
             if (!FormOpened("Form2"))
                {
                    form2 = new Form2();
                    form2.Show(this);
                }
            if (this.listBox1.SelectedIndex > -1)
            {
                string item = listBox1.SelectedItems[0].ToString();
                if (!list.Contains(item))
                    list.Add(item);
                form2.PopulatingComboBox(list);
            }
        }

        private bool FormOpened(String sFormName)
        {
            bool isFound = false;
            foreach (Form form in this.OwnedForms)
            {
                if (form.Name == sFormName)
                {
                    isFound = true;
                    break;
                }
            }
            return isFound;
        }
    }

//FORM2:
public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        public void PopulatingComboBox(List<string> list)
        {
            this.comboBox1.Items.Clear();
            for (int i = 0; i < list.Count; i++)
            {
                this.comboBox1.Items.Add(list[i]);
            }
        }
    }

The code checks if the item in comboBox2 on form2 already exists. If yes, then the selected item in listBox (on form1) is not passed to comboBox.

Hope it helps,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

I did a simple example of how populate and remove items (selected items) from comboBox and listBox:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Nov23TextCombo
{
    public partial class Form1 : Form
    {
        //
        //ADD LISTBOX AND COMBOBOX ON A FORM!
        //AND TWO EVENTS:
        //1. comboBox1_SelectedIndexChanged
        //2. listBox1_SelectedIndexChanged
        //
        public Form1()
        {
            InitializeComponent();
            PopulatingComboBox();
            PopultingListBox();
        }

        private void PopulatingComboBox()
        {
            this.comboBox1.Items.Add("Single item");
            string[] array = new string[] { "item 1", "item 2", "item 3" };
            for (int i = 0; i < array.Length; i++)
            {
                this.comboBox1.Items.Add(array[i]);
            }
        }

        private void RemovingSelectedItemComboBox()
        {
            if (this.comboBox1.SelectedIndex > -1)
            {
                int itemIndex = this.comboBox1.SelectedIndex;
                this.comboBox1.Items.RemoveAt(itemIndex);
            }
        }

        private void PopultingListBox()
        {
            this.listBox1.Items.Add("Single item");
            string[] array = new string[] { "item 1", "item 2", "item 3" };
            for (int i = 0; i < array.Length; i++)
            {
                this.listBox1.Items.Add(array[i]);
            }
        }

        private void RemovingSelectedItemListBox()
        {
            if (this.listBox1.SelectedIndex > -1)
            {
                int itemIndex = this.listBox1.SelectedIndex;
                this.listBox1.Items.RemoveAt(itemIndex);
            }
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.comboBox1.SelectedIndex > -1)
            {
                if (DialogResult.No == MessageBox.Show("Do you want to remove " + this.comboBox1.Text + " from comboBox?",
                    "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                    return;
                else
                    RemovingSelectedItemComboBox();
            }
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.listBox1.SelectedIndex > -1)
            {
                if (DialogResult.No == MessageBox.Show("Do you want to remove " + this.listBox1.Text + " from listBox?",
                    "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                    return;
                else
                    RemovingSelectedItemListBox();
            }
        }
    }
}
Mitja Bonca 557 Nearly a Posting Maven

This is a simple file creator (write line by line):

string path = @"\C:\test.txt";
StreamWriter sw;
sw = File.CreateText(path);
sw.WriteLine("1st line of a 1st text");
sw.Write("1st line of 2nd text");
sw.WriteLine("2nd line of the text");
sw.Flush(); //end of file!
sw.Close();

This is how you can create and write to a file a string:

StreamWriter sw = new StreamWriter(@"c:\test.txt");
string lines = "First line.\r\nSecond line.\r\nThird line.";
sw.WriteLine(lines);
sw.Close();

the same way you can write an array:

StreamWriter sw = new StreamWriter(@"c:\test.txt");
string lines = "First line.\r\nSecond line.\r\nThird line.";
sting[] array = lines.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < array.Length; i++)
{
   sw.WriteLine(array[i]);
}
sw.Flush();
sw.Close();
Mitja Bonca 557 Nearly a Posting Maven

What kind of text are you going to write into text fine? Only some lines, or there will be plenty of text? Iam asking, because there are different alternatives for each way.

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

Yep, this is how to be done. You have create a new instance of a class ListViewItem. And when ever you want to add subitems to it, you have to call the newly created instance of a class and then called it`s subitem class to add some value into a 2nd, 3rd, 4th, ... column of a listView row.

Mitja Bonca 557 Nearly a Posting Maven

This will do the trick:
Just for into: number 1 in the square brackets represents 2dn column in dgv.

private void GetValueFromDGVToTextBox()
        {
            int row = this.dataGridView1.CurrentCell.RowIndex;
            if (row > -1)
            {
                string value = this.dataGridView1[1, row].FormattedValue.ToString();
                textBox1.Text = value;
            }
        }
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

This has nothing to do with cache. Always when you do a login, you have to check for the user`s userName and password. And if the database is empty (that means that the userName and passowrd do not exist in the database), user cannot log in. As simpe as that. You have a wrong code somewhere - you better check it out 1st before you wade into deeper problems.
PS: if you still have issues, can you please post a code in here - all of then regarding login.

Regards,
Mitja

Mitja Bonca 557 Nearly a Posting Maven

This is how you can access the varialbes (or accessors) on the other classes and pass data into them:

namespace Nov22Sample
{
    class Program
    {
        static void Main(string[] args)
        {
            MyClass1 class1 = new MyClass1();
            class1.SendingMessage();
        }   
    }

    class MyClass1
    {
        public void SendingMessage()
        {
            string str1 = "This message is going from class 1 to class 2.";
            MyClass2 myClass2 = new MyClass2();
            myClass2.str2 = str1;
            myClass2.ShowingMessage();
        }
    }

    class MyClass2
    {
        public string str2 { private get; set; }
        
        public void ShowingMessage()
        {
            Console.WriteLine("{0}", str2);
            Console.ReadLine();
        }
    }
}
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

Which software do you use for coding? If this is Visual Studio and programming language C# or VB, I would suggest you to use Crystal Reports. I have tried them all, and the one I mentioned is simple the best (in my opinion) - offers the most and its quite "easy" to use - when you get used to it a bit - but this doesn`t take long time.

Mitja Bonca 557 Nearly a Posting Maven

try this piece of code:

static void Main(string[] args)
        {
            string str1 = "Users: What is Apple?";
            string[] arrayS = str1.Split(' ');
            string str2 = arrayS[arrayS.Length - 1];
            if (str2.Contains("?") || str2.Contains("!") || str2.Contains(".") || str2.Contains(","))
                str2 = str2.Remove(str2.Length - 1, 1);
            Console.WriteLine("{0} is a frut.", str2);
            Console.ReadLine();
        }
Mitja Bonca 557 Nearly a Posting Maven

To set the dateTime to 00:00:00 you can only do:

DateTime startTine=DateTime.Today;

Where exactly do you use this code - in what kind of calculation? If you are doing with counters, its better to you TimeSpan as Momerath said a post above.
Give me some more code, maybe we can help you out to get the best possible solution.

Mitja Bonca 557 Nearly a Posting Maven

Try to change your second static method, that will fill the result in the dataTable from sqlDataAdapter:

private static DataTable LookupUser2(string RegNumber)
        {
            // where i am looking into dbs in search of where RegNumber exist.
            // ERROR COMES FROM HERE
            string connStr = ConfigurationManager.ConnectionStrings["SchooldataConnectionString1"].ConnectionString;
            const string query = "SELECT FullName,RegNumber,Sex,Level,Department,Faculty,Session FROM StudentData(NOLOCK) Where RegNumber = @RegNumber";
            DataTable result2 = new DataTable();
            using (SqlConnection conn = new SqlConnection(connStr))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand(query, conn))
                {
                    cmd.Parameters.Add("@RegNumber", SqlDbType.VarChar).Value = RegNumber;
                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    {
                        da.Fill(result2);
                    }                    
                }
            }
            return result2;
        }
Mitja Bonca 557 Nearly a Posting Maven

You have to bind to a different variable in the foreach loop, like:

 foreach(DataRow row in dt.Rows)
 {

     Out = row[1].ToString();
     In =  row[0].ToString();
  }
Mitja Bonca 557 Nearly a Posting Maven

Ketsuekiame:
I have already done a chat programs, with a server and clients who can login on the server with appropriate ip and port of the server.
Now I have found out, that one of the solution of creating card game is, that when a client who connects to server and wants to start a new game, he then can become a server to all the clients who will join to that new game.
But I am not sure how to code it. I mean the point when the client becomes the server. How this can be made?


If any example possible, even better.

Mitja Bonca 557 Nearly a Posting Maven

Thx samsylvestertty, I will check the code.
btw, what is UdpClient for? So far I was only using TcpListener and TcpClient.

Mitja Bonca 557 Nearly a Posting Maven

samsylvestertty:
if you have any example, it would be really nice.
thx in advance.
Mitja

Mitja Bonca 557 Nearly a Posting Maven

Just a note: I would like to have only ONE port opened. Not more. So one port, and the clients will be guided by some parameters, who is in which room. How is this possible to do it?