?
Solved

How do I get content aligned corectly in a WPF Combobox

Posted on 2010-01-12
8
Medium Priority
?
1,625 Views
Last Modified: 2013-11-12
I have populated a combobox in WPF with a list of data and when I have the combo box the information displays correctly.  When I select an item in the list and close the box it displays the information w/ the first part of the text hidden and it displays the last part of the text.  How can I make it so that it defaults to show the first part of the text and lets the overflow be hidden to the right of the text box.
combobox-open.jpg
combobox-closed.jpg
0
Comment
Question by:perrytaylor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 13

Expert Comment

by:Ashok
ID: 26337331
Can you show the code in XAML file for creating ComboBox?
0
 
LVL 10

Expert Comment

by:k_swapnil
ID: 26367445
Try Setting DisplayMemberPath property for the combobox
0
 

Author Comment

by:perrytaylor
ID: 26369753
<ComboBox Name="cmbLFSpindle" Height="25" SelectionChanged="cmbLFSpindle_SelectionChanged" IsEditable="True" IsReadOnly="True" MaxWidth="85" MaxHeight="25">
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:perrytaylor
ID: 26370019
Actually changing the property from iseditable = "true" to "false" fixes my problem....though it takes away the ability to edit it.  The above is the code that doesn't work..  This code does (with the caveat that the user can't edit it.
<ComboBox Height="25" Name="cmbLFSpindle" HorizontalAlignment="Left" VerticalAlignment="Top" Width="85" SelectionChanged="cmbRFSpindle_SelectionChanged" IsEditable="False" IsReadOnly="True" FlowDirection="LeftToRight" HorizontalContentAlignment="Left" MaxWidth="85" MaxHeight="25" />
                               
what should I set the displaymemberpath too?  I'm not familiar w/ that property.
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 26370024
remove  IsEditable="True"
0
 

Author Comment

by:perrytaylor
ID: 26370040
is there a way to keep it editable?
0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 2000 total points
ID: 26370259
in your selectionchanged routine

private void cmbLFSpindle_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox b = sender as ComboBox;
            b.IsEditable = false;
            b.IsEditable = true;
        }
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 26370558
of course you may want to check it first

private void cmbLFSpindle_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox b = sender as ComboBox;
if (b.IsEditable == true)
{
            b.IsEditable = false;
            b.IsEditable = true;
}
        }
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question