Hi Guys,

If you have a Text Box which you are putting in the Decimal Places such as "15.50". Then Submitting this to a Access Database then on re-fresh the data shows in the grid view as "15.5". Where abouts should this be modified so that it shows Decimal Places?

Is it on the Access DB Layout and how it's store or should there be come amendment on the code side? It looks like the GridView is removing the trailing '.00's' ??

Many thanks for any help.

Attachments Capture2.JPG 27.31 KB Capture1.JPG 32.41 KB Capture3.JPG 35.13 KB Capture4.JPG 52.24 KB

Sorry Guys,

Found the answer. Was able to go into the Gridview and change the properies to show 2 Decimal Places..

Thank you anyways.. Hope this helps someone else out!

Attachments Capture5.JPG 168.81 KB

Click HereAh.. It looks like I spoke to soon guys...

Due to their being a 'Date Format' within the GridView its now coming up with 'N2' instead of the Date.

How can I filter out this column? (Attached Screenshot).

Also Below is the snippet of Code I'm currently using. When a user select the account from the DGV1 it will pull up the corresponding Orders in DGV2 via the ODBC Connection.

  private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            //If the Radio Button is checked the Script between the {} will be run//
            if (radioButton1.Checked == true)
            {
                //Looks at the row Selected in the GridView and then takes the Account Number and Stores in a Int64 called 'Customer ID'//
                DataGridViewRow drow = dataGridView1.SelectedRows[0];
                //Int64 CustomerID = Convert.ToInt64(drow.Cells[0].Value);
                string CustomID = Convert.ToString(drow.Cells[1].Value);


                //Sets the Selected Account and shows inside the Text Boxes on the right-hand side of the screen//
                txtAccRef.Text = dataGridView1.SelectedCells[1].Value.ToString();
                txtAccName.Text = dataGridView1.SelectedCells[2].Value.ToString();
                txtAccAddr1.Text = dataGridView1.SelectedCells[3].Value.ToString();
                txtAccAddr2.Text = dataGridView1.SelectedCells[4].Value.ToString();
                txtAccTown.Text = dataGridView1.SelectedCells[7].Value.ToString();
                txtAccPostCode.Text = dataGridView1.SelectedCells[6].Value.ToString();
                txtAccCounty.Text = dataGridView1.SelectedCells[5].Value.ToString();


                //Message to Test ID has been stored//
                //MessageBox.Show("Customer ID Stored");

                //Creates new versions of the Connection string and Data Set//
                con = new System.Data.OleDb.OleDbConnection();
                ds3 = new DataSet();

                //The actual connection to the database//                               //XML Path to Data Base held in string...sneaky like a Ninja!//
                con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =" + textBox1.Text.ToString();

                //The SQL String you need to pass into the Data Adapter to collect the information//
                string OrdersCashCustomerSQL = "SELECT cashID, cashQTY, cashDescription, cashSupplier, cashDate, cashCost, cashSell, CashAccountRef_FKID from cashOrders INNER JOIN CashCustomers ON cashOrders.CashAccRef_FKID = cashCustomers.CashAccRef WHERE cashCustomers.CashAccRef = '" + CustomID.ToString() + "'";

                da = new System.Data.OleDb.OleDbDataAdapter(OrdersCashCustomerSQL, con);

                //The Data Adapater (da) is told to fill the DataSet (ds) with the information pulled from the SQL Query and call this fill "cashCustomers"//
                da.Fill(ds3, "OrdersCashCustomers");

                //Opens the connection//
                con.Open();

                //Closes The Connection//
                con.Dispose();

                //Tells the dataGridView to load with the information stored in table called 'cashCustomers' in the DataSet (DS)//
                dataGridView2.DataSource = ds3.Tables["OrdersCashCustomers"];



                //Change the Headers on the DataGridView2//
                dataGridView2.Columns["cashQTY"].HeaderText = "QTY";
                dataGridView2.Columns["cashDescription"].HeaderText = "DESCRIPTION";
                dataGridView2.Columns["cashSupplier"].HeaderText = "SUPPLIER";
                dataGridView2.Columns["cashDate"].HeaderText = "DATE";
                dataGridView2.Columns["cashCost"].HeaderText = "COST (£)";
                dataGridView2.Columns["cashSell"].HeaderText = "SELL (£)";

                //Hide Columns on DataGridView2//
                dataGridView2.Columns["cashID"].Visible = false;
                dataGridView2.Columns["CashAccountRef_FKID"].Visible = false;

            }

Any help with this is most grateful :)

Thanks in Advance.

Edited 2 Years Ago by sundog1: Forgot screenshot

Attachments Capture7.JPG 36.04 KB

Anyone got any ideas on this please?

Do I need to 'Convert' the particular Column

Hi Guys, I've been playing around with this.. and I assume I have to convert this particular data.

I know its DGV releated and when I run the Export to Excel routine from the system it shows the date correctly.

Attachments Capture8.JPG 97.54 KB

Click HereHI @ddnabe.. Thanks for your reply..

I have looked into this and I've also read that I should be able to Config Each column Accordingly.

I'm Currently using this piece of code:

        //Change the Headers on the DataGridView2//
                dataGridView2.Columns["cashQTY"].HeaderText = "QTY";
                dataGridView2.Columns["cashDescription"].HeaderText = "DESCRIPTION";
                dataGridView2.Columns["cashSupplier"].HeaderText = "SUPPLIER";
                dataGridView2.Columns["cashDate"].HeaderText = "DATE";
                dataGridView2.Columns["cashCost"].HeaderText = "COST (£)";
                dataGridView2.Columns["cashSell"].HeaderText = "SELL (£)";

                //Trying to for change of "casDate" to a type of DateTime//
                this.dataGridView2.Columns["cashDate"].ValueType = typeof(DateTime);

Currently it does not error, but it also does not Show the DateTime in the GridView when running either..

Currently stepping through it to see what happens.

Any ideas guys?

Edited 2 Years Ago by sundog1: Added Images

Attachments Capture9.JPG 120.43 KB Capture10.JPG 24.64 KB

Try to set the format of the date column to something like this:

this.dataGridView2.Columns["cashDate"].DefaultCellStyle.Format = "dd/MM/yyyy";

Hi ddanbe,

Many thanks for your response!

I think I'm nearly there. However the Month is not showing up? Please see screenshots attached.

the DataSet seemsto be filled with the correct info.. Just the way the form is displaying.

Any ideas?

Attachments Capture12.JPG 170.76 KB Capture11.JPG 27.08 KB

Ah, Found the issue.. I was using 'LowerCase' "mm" for the Month insted of "MM"..

Do you know the reason behind this?

This question has already been answered. Start a new discussion instead.