SelectRowWithText not selecting a matching row (Desktop Popup)

I have a popup menu that currently has two predefined options. There will eventually be more:

Mono8
Mono16

These values match parameters stored on a frame grabber board. I am reading the value on the frame grabber in the Window’s Opening event, and want to pre-select the correct option from this pulldown.

FrameGrabber.frameBPP = FrameGrabber.CXPGetFGParameter("camera", "PixelFormat") 
//This puts the string "Mono16" into FrameGrabber.frameBPP
var bpp as string = FrameGrabber.frameBPP
//This has the value "Mono16"
puBPP.SelectRowWithText(bpp)

The only reason I’m putting FrameGrabber.frameBPP into a string called bpp is for ease of debugging, so it’s right there when things go awry. Which they do.

When the code above is called, I get an InvalidArgumentException in puBPP.SelectRowWithText(bpp).

I can clearly see right in front of me that the text matches exactly. I even copy/pasted the value I was getting from the frame grabber in the debugger, and replaced the “Mono16” in the IDE’s Inspector for the popup with that text just in case there was something weird (invisible). And I keep getting this. Any ideas?

can it be a text encoding problem ?

1 Like

You get this?
image

Is “Mono16” UTF-8?
image

Any invisible characters if you select Binary?
image

Hmm. It’s saying it’s 7 bytes, not 6 like yours. and there are two extra digits in the Binary display that aren’t in your example.

image

…which if I recall means it’s a Cstring. And in fact, this line returns a cstring from the frame grabber:

FrameGrabber.frameBPP = FrameGrabber.CXPGetFGParameter("camera", "PixelFormat")

So that’s probably the issue there. Ultimately I need to ensure that the data going TO the frame grabber is a cstring. in the CXPGetFGParameter() method should I be converting the value from cstring and then if the value changes in this popup I convert to a cstring before calling the DLL to write to the frame grabber? The value of frameBPP is used in lots of places but always handled as a Xojo String.

This had been working fine where I was originally using the popup menu’s selected item index number to identify the selection and then convert that to either “Mono8” or “Mono16” as a string in an if/then statement. The problem was that I had several of these and wanted to streamline it, so I decided to just have the popup display the actual text that gets written to/read from the frame grabber board since it’s human readable. That’s when this issue began.

The 00 is the string terminator. For CStrings that is normal. If you read it into a CString variable and assign it to a standard string it should be stripped.

Yeah I just changed the line that creates the bpp variable to this:

var bpp as CString = FrameGrabber.frameBPP

and now it works.

2 Likes