DataGridView questions.

G

Guest

I have a few DataGridView questions that hopefully someone will be able to
help me with some or all of them.

1) I have a DataGridView that is bound to a DataTable (DataSource set to a
table). When I progromatically add a row to the DataTable the DataGridView is
updated as it should be. The problem comes with editing. I have marked some
of the columns in the designer as ReadOnly = False, but for some reason I am
not able to edit the new added row. I look at the property in the debugger
and it is still ReadOnly = False but I still cannot edit the cell for the
column that I marked ReadOnly = False. I saw in the documentation that the
ReadOnly attribute for the row takes precedence over the column attribute.
Maybe this is what is happening? How do I set the ReadOnly property for the
row? Or more precisely how do I enable one or more columns for editting?

2) I handle a CellFormatting event and change certain columns display value
to a proper currency format. Now I would like to change the alignment so the
decimal points line up. It seems that the default alignment is to the left.
How do I change the alignment of the values in a column to be right-aligned?

Thank you.

Kevin
 
G

Guest

For the first question I checked the columns that the DataGridView is bound
to for example:


_dsManualOrder.dtManualOrderItemDiscount.Columns("quantity").ReadOnly

And this ReadOnly property is False. Something else is preventing me from
editing.

Kevin
 
G

Guest

I think I have partially solved my edit problem. It seems that when a row is
added (via binding) to the DataGridView it is added with the ReadOnly
attribute set to True. But this brings up a couple of other questions. Is it
possible to set the default ReadOnly value for a Row to be False? If this is
not possible, if a row has been added to a bound table and the binding causes
a row to be added to the DataGridView then how do I tell which row was just
added?

Thank you.
 
G

Guest

After every row is added I execute the following code:

dgvOrderItemsDiscount.Columns("DiscountQuantity").ReadOnly =
False
dgvOrderItemsDiscount.Columns("DiscountPercentage").ReadOnly
= False
dgvOrderItemsDiscount.Columns("DiscountUnitPrice").ReadOnly
= False
dgvOrderItemsDiscount.Rows(dgvOrderItemsDiscount.Rows.Count
- 1).ReadOnly = False

I still am not able to edit any column in the newly added row.
(dgvOrderItemsDiscount is the DataGridView in question)

Any suggestions?

Thank you.

Kevin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top