tags:

views:

237

answers:

3

Is there a simple way to format numbers in a Winforms 1.1 datagrid? The Format property of the DataGridTextBoxColumn seems to be completely ignored. I know there is a solution that involves subclassing a Column control, and it's fairly simple, but was hoping there might be some trick to making the Format property just work.

Thanks
Mike

A: 

I am fairly certain I have used the Format property successfully in the past. Can you please post the relevant code?

homeskillet
+1  A: 

My personal opinion is that a datagridcolumnstyle is the way to go. Without seeing the code that you have, I can't say for certain why your formatting isn't taking hold when no style is defined - but mixing in formatting with data calculations and other parts of the code can get very messy very quickly.

Creating a new column style class is very clean, and if you have to use the same formatting again in another datagrid, it's as easy as pie to reuse it.

Here's the Microsoft Documentation that may get you started in the right direction.

Jeffrey
A: 

I did subclass and it was easy and did work. I still don't like it so much. I was already subclassing column styles for other reasons. I'd rather handle all databinding myself, where I can more easily change it and test it. This whole mixing of the UI with the data is old school, and not in a good way.

Thanks very much for your answers, it's good to have second opinions.

Mike

Mike