lighthead 55 Junior Poster in Training

You put the message box in the wrong place.

if (tb != null)
                    {  
                        if(!string.IsNullOrEmpty(tb.Text))
                        {
                            Form2 form2 = new Form2();
                            form2.Show();
                        }
                        else
                       {
                          //error message goes here...
                       }
                    }
wingers1290 commented: Ecellent +1
lighthead 55 Junior Poster in Training

I was curious as in my fair share of crashes , all the programs show some sort of messsagebox with the trace. The OP described it as 'the program has stopped working, windows is checking for a solution' , which is new to .NET crashes (at least for me).

@ddanbe
Its a welcome relief.:) This forum is sleeping now anyway.

lighthead 55 Junior Poster in Training

I was curious about why a .NET program crashes without showing a debugging message that you generally see.
Instead I find you too...carry on you two :)
Haha this is i more interesting.:P

lighthead 55 Junior Poster in Training

printf returns the number of bytes printed to the terminal. So the expression printf("HI")-2 returns 0. We end up with while(0){} .
For further clarification on printf visit here.
As printf is the expression used as the condition for the 'while' loop, no semicolon is required.It is same as

int val = printf("HI");
while(val - 2)//value of val is 2.
{

}
lighthead 55 Junior Poster in Training

1) Use the code tags as mentioned.
2)

TC = getchar();

Has been used 2 times in a loop, the second value is being over written and is lost.
3) And the construct (TC = getchar() != '\n') actually is read by the compiler as (TC = (getchar() != '\n')) .
Hence it gives TC a value of 1 meaning true until '\n', where it gives 0.
So, use either one of the constructs.

while ( (TC = getchar()) != '\n')
{
//...
}

or

TC = getchar();
while ( TC != '\n')
{
//...
TC = getchar();
}

4)When you are printing the results you are passing only two parameters when 3 are required. The third is the percentage calculation. Make sure to cast the value to float before you calculate the percentage. (float)AA[TC]/TL)

lighthead 55 Junior Poster in Training

Adding to that.
1) The reference types can have more than one reference to the themselves. It would be ambiguous getting variable names even if you were able to access such information.
2) The debugger can know names of variables and other information from the metadata. But only when compiled for debugging and you cannot access them programmatically.
3) You can do this though.

Ramy Mahrous commented: Very nice link. +8
lighthead 55 Junior Poster in Training

This might be helpful.

lighthead 55 Junior Poster in Training

Mark it as solved.

lighthead 55 Junior Poster in Training

Your function is correctly returning a list of at most 'num' lines in the file. There were no blank lines. You might want to recheck other parts of the program.

lighthead 55 Junior Poster in Training

A better method is to use a RegularExpressionValidator. As post #3 suggests mark this post as solved.

lighthead 55 Junior Poster in Training

Is it a ASP.NET application or windows forms. Form post 4 it seems like a windows forms.
If its an ASP.NET thing then post 3 answers your question.If you need more detailed help provide more code or project as 'adatapost' sugested.

lighthead 55 Junior Poster in Training
private void button1_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (row.Selected)//check if row is selected
                {
                    using (SqlConnection conn = new SqlConnection(ConnectionString))
                    {
                        SqlCommand com = new SqlCommand("delete_row", conn);//remove row from database
                        com.CommandType = CommandType.StoredProcedure;
                        com.Parameters.Add(new SqlParameter("@id", Convert.ToInt32(row.Cells[0].Value)));//unique id field of the datarow
                        conn.Open();
                        com.ExecuteNonQuery();
                        conn.Close();
                        dt.Rows.RemoveAt(row.Index);//remove row from the datatable that is bound to the gridview.
                    }
                }
            }

Hope this answers your question.

lighthead 55 Junior Poster in Training

No, you cant do that. The code is different for the forms.
You can try this
1) Detect the click event on the datagrid

dataGridView1.CellContentClick += new DataGridViewCellEventHandler(dataGridView1_CellContentClick);

2)Handle check for the right control do do the action required

void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex != 2)//check the column of the checkbox
                return;
            // your action go here
           //get the id for row, delete from database, delete from the  datatable that is source of your database            
        }

I dont know if there is a better way.

lighthead 55 Junior Poster in Training

The solution provided in the previous thread of yours was a better one, i have modified it to make the colours permanent.
Hope this solves your problem.

lighthead 55 Junior Poster in Training

Can you tell me where you have added the lines.

lighthead 55 Junior Poster in Training

1) Create a new setting in Settings.Settings file in properties and set its type as System.Drawing.Color.
2) Where ever in your code you choose a colour from the user, set the property and save it.

Properties.Settings.Default.colour = c1.Color; //set the selected colour //to the setting colour which you had created.
Properties.Settings.Default.Save();

3) When Use this setting to set the colour where you require.

lighthead 55 Junior Poster in Training

The simplest way i think would be

private void textBox1_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if(textBox1.Text!="")
                Convert.ToDouble(textBox1.Text);
            }
            catch
            {
                textBox1.Text = "";
            }

        }
lighthead 55 Junior Poster in Training

The problem in filltable method :
for ( column=1;column <= *(table[row]);column++); //remove the semicolon :)

tux4life commented: Yes! +13
lighthead 55 Junior Poster in Training

If you want to change colour of all the forms onload of the form, then write assign the colour of the form in the onload function of the form.

In form1

        public static System.Drawing.Color x1;
        public Form1()
        {
            InitializeComponent();
            ColorDialog cd = new ColorDialog();
            cd.ShowDialog();
            x1 = cd.Color;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 oj = new Form2();
            oj.Show();
        }

In form2
               public Form2()
		{
			InitializeComponent();
                        this.BackColor = Form1.x1;
		}

You can do the same for all the forms and i didn't understand why u have to create a new object of form1 in form3.

Hope this solves your problem.

lighthead 55 Junior Poster in Training

its a web application or forms..
if it is forms, it is enough if u give DataSource.

lighthead 55 Junior Poster in Training

There are many ways to bind data to the DataGridView. The method i use is
1. Create columns in the DataGridView control.
2. Create DataTable with the same columns.
3. Create Rows for the Datatable and insert data in to the row.
4. Set DataSource property of the DataGridview control to the created table.
5. Call DataBind method.

I think DataBinding is a property not a method.

kvprajapati commented: Very good +5