What? Concatenating isn't working?

Most probably your strings have greater length than the length you have
provided in Padding.

In this line,

return String.Format("{0},{1}({2})", LastName.Padright(20),
FirstName.Padright(10),
EmployeeNumber);

*LastName* should NOT have more than 20 characters while *FirstName* should
NOT have more than 10 characters.



On Tue, Apr 13, 2010 at 7:47 PM, Benj Nunez <[email protected]> wrote:

> I checked it out. Still no go. :(
>
> On Apr 13, 10:05 pm, Benj Nunez <[email protected]> wrote:
> > Ah I see. Well, I'll check the font first. Maybe that will do the
> > trick. But I'm still open for suggestions.
> > Thanks Arsalan. ;)
> >
> > Benj
> >
> > On Apr 13, 12:54 pm, Arsalan Tamiz <[email protected]> wrote:
> >
> > > Concatenating is good workaround but as you can see you are having the
> > > alignment problem this is because the normal fonts like Sans Serif,
> Arial or
> > > Tahoma does NOT have fixed width character set. You can use Courier New
> or
> > > Lucida Console fonts because these fonts have fixed width character set
> and
> > > thus will solve your alignment problem
> >
> > > There are other ways which you can use to customize the built-in
> ComboBox. I
> > > think the simplest way is to set the *DrawMode* property =
> > > *OwnerDrawFixed*and then use ComboBox's
> > > *DrawItem* event. But in this way you will be responsible for
> displaying
> > > items using drawing routines like *DrawString()* etc. which is a bit
> complex
> > > way to do.
> >
> > > On Mon, Apr 12, 2010 at 8:52 PM, Benj Nunez <[email protected]>
> wrote:
> > > > Hello experts,
> >
> > > > I need to know if it's possible to align the fields defined in a
> > > > combobox? Right now I'm having difficulty
> > > > implementing a multi-column combobox so I'll stick to concatenating
> > > > one or more fields by overriding the
> > > > toString() method from a dto like so:
> >
> > > > class Contacts
> > > > {
> > > >   string LastName;
> > > >   string FirstName;
> > > >   string EmployeeNumber;
> > > >   ...
> > > > }
> >
> > > >    public override string ToString()
> > > >        {
> > > >            return String.Format("{0},{1}({2})", LastName,
> > > >                FirstName, EmployeeNumber);
> > > >        }
> >
> > > > I tried doing this:
> >
> > > >    public override string ToString()
> > > >        {
> > > >            return String.Format("{0},{1}({2})",
> > > > LastName.Padright(20),
> > > >                FirstName.Padright(10), EmployeeNumber);
> > > >        }
> >
> > > > Still, the fields don't line up properly. Although when called using
> > > > TextWriter
> > > > or Console.writeline(), it is possible. any ideas?
> >
> > > > Benj
> >
> > > > --
> > > > To unsubscribe, reply using "remove me" as the subject.
>

Reply via email to