Long Text string in Combobox aligning right (shouldn't be) andcutting off head of string instead of

N

NET CF Questions

We have a combobox populated with data (let's say product names) with
some names being longer than the pull down window (box?) so part of
the name is not shown.

This is not a problem.

Our problem is that instead of showing the name from the left (or in
other words the start of the name) it shows it from the right so the
head of the product name is not shown.

As an example of what's happening, say the full text in the pull down
row is:

"Zebra Pens Gel Type"
Instead of displaying
"Zebra Pens Gel"
(which is acceptable)
it displays
"a Pens Gel Type"

The code for the combobox is;

Here is the code:

With cob_MyCombo
.DisplayMember = "DISP"
.ValueMember = "VAL"
.DataSource = ary_ArrayList
.SelectedIndex = int_SelectIndex
If str_DefaultValue <> "" Then
.Text = str_DefaultValue
End If
End With


Everything I've heard tells me the default is to show the string from
the left so I have no idea what's happening here.
Any ideas or what I need to do to fix this?
 
P

Paul G. Tobey [eMVP]

Let me see if I understand. The ComboBox is set for DropDown as the type,
right? And it's not the items in the drop-down list that are off the end,
but the currently-selected one, right? That actually *is* the way it's
supposed to work because the whole entry in the EDIT control bar of the
combo is selected. I suppose that, when the selection changes, you could
set suitable selection bounds so that the insertion point is at the *start*
of the text, rather than the whole text entry being selected. Are you sure
that the item needs to be editable, anyway? A DropDownList might be a
better mode, if the user never has to edit the entry.

Paul T.
 
N

NET CF Questions

It does need to be edited.
Editable?
I suppose that, when the selection changes, you could
set suitable selection bounds so that the insertion point is at the *start*
of the text, rather than the whole text entry being selected.

You wouldn't happen to have an example of code to do this would you?
 
P

Paul G. Tobey [eMVP]

Interestingly, native code *does* show the left edge of the string with no
extra work. I've verified that the following pattern works in .NET CF 3.5,
though:

private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
{
// Set up a timer to change the selection,
// after the text in the EDIT field has been
// changed.
timer1.Interval = 20;
timer1.Enabled = true;
}

private void timer1_Tick(object sender, EventArgs e)
{
// Time to set the insertion point, but first
// turn off the timer.
timer1.Enabled = false;
comboBox1.Select(0, 0);
}

Paul T.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
 
N

NET CF Questions

Thank you, I'll give that to the developers.
Interestingly, native code *does* show the left edge of the string with no
extra work.

Is there a global setting or something that we might have changed
somewhere to make it behave like this?

I'm probably asking this incorrectly, but since we've defined neither
left nor right but it's showing from the tail rather than head, could
we have something set somewhere that we need to change?



Interestingly, native code *does* show the left edge of the string with no
extra work. I've verified that the following pattern works in .NET CF 3.5,
though:

private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
{
// Set up a timer to change the selection,
// after the text in the EDIT field has been
// changed.
timer1.Interval = 20;
timer1.Enabled = true;

}

private void timer1_Tick(object sender, EventArgs e)
{
// Time to set the insertion point, but first
// turn off the timer.
timer1.Enabled = false;
comboBox1.Select(0, 0);

}

Paul T.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT

com> wrote in messagenews:[email protected]...
Let me see if I understand. The ComboBox is set for DropDown as the type,
right? And it's not the items in the drop-down list that are off the end,
but the currently-selected one, right? That actually *is* the way it's
supposed to work because the whole entry in the EDIT control bar of the
combo is selected. I suppose that, when the selection changes, you could
set suitable selection bounds so that the insertion point is at the
*start* of the text, rather than the whole text entry being selected. Are
you sure that the item needs to be editable, anyway? A DropDownList might
be a better mode, if the user never has to edit the entry.
 
P

Paul G. Tobey [eMVP]

No. My guess is that the ComboBox class in managed code is not using a
COMBOBOX control from native code, but is using a listbox and an EDIT box
and trying to make it act like the native control. They missed
compatibility on this one is all.

Paul T.

NET CF Questions said:
Thank you, I'll give that to the developers.
Interestingly, native code *does* show the left edge of the string with no
extra work.

Is there a global setting or something that we might have changed
somewhere to make it behave like this?

I'm probably asking this incorrectly, but since we've defined neither
left nor right but it's showing from the tail rather than head, could
we have something set somewhere that we need to change?



Interestingly, native code *does* show the left edge of the string with
no
extra work. I've verified that the following pattern works in .NET CF
3.5,
though:

private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
{
// Set up a timer to change the selection,
// after the text in the EDIT field has been
// changed.
timer1.Interval = 20;
timer1.Enabled = true;

}

private void timer1_Tick(object sender, EventArgs e)
{
// Time to set the insertion point, but first
// turn off the timer.
timer1.Enabled = false;
comboBox1.Select(0, 0);

}

Paul T.

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT

com> wrote in messagenews:[email protected]...
Let me see if I understand. The ComboBox is set for DropDown as the
type,
right? And it's not the items in the drop-down list that are off the
end,
but the currently-selected one, right? That actually *is* the way it's
supposed to work because the whole entry in the EDIT control bar of the
combo is selected. I suppose that, when the selection changes, you
could
set suitable selection bounds so that the insertion point is at the
*start* of the text, rather than the whole text entry being selected.
Are
you sure that the item needs to be editable, anyway? A DropDownList
might
be a better mode, if the user never has to edit the entry.
We have a combobox populated with data (let's say product names) with
some names being longer than the pull down window (box?) so part of
the name is not shown.
This is not a problem.
Our problem is that instead of showing the name from the left (or in
other words the start of the name) it shows it from the right so the
head of the product name is not shown.
As an example of what's happening, say the full text in the pull down
row is:
"Zebra Pens Gel Type"
Instead of displaying
"Zebra Pens Gel"
(which is acceptable)
it displays
"a Pens Gel Type"
The code for the combobox is;
Here is the code:
With cob_MyCombo
.DisplayMember = "DISP"
.ValueMember = "VAL"
.DataSource = ary_ArrayList
.SelectedIndex = int_SelectIndex
If str_DefaultValue <> "" Then
.Text = str_DefaultValue
End If
End With
Everything I've heard tells me the default is to show the string from
the left so I have no idea what's happening here.
Any ideas or what I need to do to fix this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top