ANAT2403
asked on
price column in datagridview
In WInforms VS2005 with C# I have a datagridview and I want to show a column with price.
How do I set this column?
Anat
How do I set this column?
Anat
ASKER
this column already exist in my datatable and is declared as a decimal type. In the database it is declared as money. the question is what typw to give this field in the datagridview so that the currency will show?
Anat
Anat
When you add the column to the DataGridView, what are you currently using for:
newColumn.ValueType = ?
Jim
newColumn.ValueType = ?
Jim
ASKER
This is the way I declare this column:
dgvColText = new DataGridViewTextBoxColumn( );
dgvColText.Name = "Price";
dgvColText.DataPropertyNam e = "Price";
pdGVInventory.Columns.Add( dgvColText );
Do I have to declare it differently? and what properties do I have to add so that I will control the digits
after the decimal points and the currency symbol?
Thankyou
Anat
dgvColText = new DataGridViewTextBoxColumn(
dgvColText.Name = "Price";
dgvColText.DataPropertyNam
pdGVInventory.Columns.Add(
Do I have to declare it differently? and what properties do I have to add so that I will control the digits
after the decimal points and the currency symbol?
Thankyou
Anat
Anat - Do the rows contain different kinds of currency in this column, or are all the same? If different, how do you know which row contains which type? If the same, it is probably easiest to add the currency symbol to the column header.
When you say it is "money" in the DB, can I infer from that you are using SQL Server?
Jim
When you say it is "money" in the DB, can I infer from that you are using SQL Server?
Jim
Sorry - one more question: Are you doing any arithmetic with the values from this column in the DataTable?
Jim
Jim
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad you found it. Good luck.
Jim
Jim
ASKER
By the way if I want to show a specific currency do I have to change the culture or is there
another way?
Thankyou
Anat
another way?
Thankyou
Anat
Closed, 500 points refunded.
modus_operandi
Community Support Moderator
modus_operandi
Community Support Moderator
>> Pseudo Code to create a dummy datatable and making the datagrid to display a Price Column
DataTable dtTable = new DataTable();
dtTable.Columns.Add("Price
dr1 = dtTable.Rows.NewRow();
dr2 = dtTable.Rows.NewRow();
dr3 = dtTable.Rows.NewRow();
dr1[0] = 1;
dr1[0] = 2;
dr1[0] = 3;
dataaGridView1.DataSource = dtTable;