[.net] c# how to make my datagridview work like Excel?

Started by
13 comments, last by nick5454 14 years, 8 months ago
Is there a way to get my datagridview to work like Excel? For example, then the user types =1+1 into any of the cells, then then cell will return 2. Thanks.
Advertisement
I'm sure there is a "CellTextChanged" or similar event that you can catch. Check if the value begins with a "=", then you parse the expression and calculate the result.

There is no "WorkLikeExcel" property though :).
----------------------------------------MagosX.com
well pretty much want to full range of excel formulas. is there something that can be added?
You could use IronPython and run the table values through the eval() function.
hmm can you please explain how that works in more detail? can it do cell referencing and if statements?
Quote:Original post by shrek2
hmm can you please explain how that works in more detail? can it do cell referencing and if statements?

[google]

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

How much like excel does it need to be, the syntax is a bit different but Python is a complete language that is more than enough for basic in app scripting.
Quote:Original post by Kaze
How much like excel does it need to be, the syntax is a bit different but Python is a complete language that is more than enough for basic in app scripting.


basic arithmetic, if statements, and cell referencing.

For example,

=1+1
=if(c2=c3,4,0)

can u give me an idea on how to implement this? i guess i don't understand what needs to be done her if i use python. thanks.
Well, you could just directly embed an excel object in your app. This will get you pretty much the full excel experience, although it will create a dependency on excel (i.e. your app won't run an machines that don't have excel installed)
if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight
Unless you take ChaosEngine's solution, then there is nothing (that I am aware of) that lets you do it without having to parse and evaulate the cells yourself.

Why do you think Microsoft charge so much for Excel/Office if it could all be built using off-the-shelf components for free anyway?

This topic is closed to new replies.

Advertisement