Setting attributes at runtime on a DataGrid

partham

Active member
Joined
Dec 27, 2005
Messages
41
Location
Kolkata, India
Programming Experience
10+
Dear Sir,

In a datagrid, we are displaying among others 2 columns which have a relation. They are "Data Type" and "Max Length". If "Data Type" is Date, the length should be 8 and it should not be modifiable. If the "Data Type" is Numeric, the maximum length should be 19. Otherwise, maximum length should be 255.

How can we acheive making the column enabled/disabled on changing rows?

How can we impose these contraints? Our though was to put the constraint on the underlying DataTable and thus disallow invalid values. Is this approach okay?

How can we set the value of another column depending on the value in one column? We are thinking of using the CurrentCellChanged Event. Is it the best method?

We have used the CurrentCellChanged event to track if the row selection has been changed? Is this the best method? We do not think so because this fires when we are within the row as well. We are unable to find an event which senses the row change. Is there one?

Thanks in advance for your time and suggestions.

Regards,
 
Dear Sir,

We changed our program to conduct the tasks as follows:

In a datagrid, we are displaying among others 2 columns which have a relation. They are "Data Type" and "Max Length". If "Data Type" is Date, the length should be 8 and it should not be modifiable. If the "Data Type" is Numeric, the maximum length should be 19. Otherwise, maximum length should be 255.

How can we acheive making the column enabled/disabled on changing rows?

We acheived this by programming the CurrentCellChanged event for the DataGrid. Here based on the values of the current row, we made the column ReadOnly.

How can we impose these contraints? Our though was to put the constraint on the underlying DataTable and thus disallow invalid values. Is this approach okay?

I think this is not possible as DataTable Constraints cane be only Primary Key, Foreign Key and Unique Key apart for datatype check.

How can we set the value of another column depending on the value in one column? We are thinking of using the CurrentCellChanged Event. Is it the best method?

We programmed the DataColumnChanging event for the same.

We have used the CurrentCellChanged event to track if the row selection has been changed? Is this the best method? We do not think so because this fires when we are within the row as well. We are unable to find an event which senses the row change. Is there one?

We now use DataColumnChanging, DataColumnChanged, DataRowChanged and DataRowChanged events of the DataGrid.


Please let us if there are any better techniques.

Regards,
 
Back
Top