U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » GridCtrl empty cells pasted from Excel
Re: GridCtrl empty cells pasted from Excel [message #17695 is a reply to message #17362] Tue, 26 August 2008 12:07 Go to previous messageGo to previous message
koldo is currently offline  koldo
Messages: 3458
Registered: August 2008
Senior Veteran
Well, I have found the problem.

This function gets the exception in "int(val)" because when pasted from outside GridCtrl, a "1" instead of being an int is a string!!

The function:

struct DispPM : GridDisplay
{
virtual void Paint(Draw &w, int x, int y, int cx, int cy, const Value &val, dword style, Color &fg, Color &bg, Font &fnt, bool found, int fs, int fe)
{
String text;
if(!val.IsNull())
text = int(val) > 0 ? "Yes" : "No";
else
text = "";
GridDisplay::Paint(w, x, y, cx, cy, Value(text), style, fg, bg, fnt, found, fs, fe);
}
};

So changing
text = int(val) > 0 ? "Yes" : "No";

with
if (val.Is<String>()) {
String s = val;
if (s == "1")
text = "Yes";
else
text = "No";
} else
texto = int(val) > 0 ? "Yes" : "No";

it works.

The simplest way to get the exception is:

String s = "1";
Value val = s;
int i = int(v);

Question: Is there a way to convert a Value to int in a safe way?


Best regards
IƱaki
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: adding row from another window and updating GUI
Next Topic: Unicode character paste in GridCtrl
Goto Forum:
  


Current Time: Fri May 15 17:06:13 GMT+2 2026

Total time taken to generate the page: 0.00934 seconds