Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8396197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:28:40+00:00 2026-06-09T20:28:40+00:00

As an attempt to color text in ListBox i found this guide C# :

  • 0

As an attempt to color text in ListBox i found this guide C# : change listbox items color (i am using windows forms application on visual studio 2012).
The code is working but the problem is that i want to use the textbox in a Right to Left mode, but when i change it in the ListBox settings it does not work, so i assume that it needs to be changed in the code somehow, this is what i need your help for.
Thank you very much!
Alon

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:28:42+00:00Added an answer on June 9, 2026 at 8:28 pm

    Your y position is 0, so everytime you insert a message it’s on the left side.
    To put it on the right side you have recalculate the postion.

    Look at the following example.

    private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
    {
        MyListBoxItem item = listBox1.Items[e.Index] as MyListBoxItem; // Get the current item and cast it to MyListBoxItem
        if (item != null)
        {
            e.Graphics.DrawString( // Draw the appropriate text in the ListBox
                       item.Message, // The message linked to the item
                       listBox1.Font, // Take the font from the listbox
                       new SolidBrush(item.ItemColor), // Set the color 
                       width - 4, // X pixel coordinate
                       e.Index * listBox1.ItemHeight,
                       new StringFormat(StringFormatFlags.DirectionRightToLeft)); // Y pixel coordinate.  Multiply the index by the ItemHeight defined in the listbox.                
        }
        else
        {
            // The item isn't a MyListBoxItem, do something about it
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the following code to attempt to get the font color of
I have the following css and jquery code to attempt to change the text
First attempt to use this cool site - after searching for 2 hours: So
This is my first attempt at responsive design, so I'm keeping it simple. I
When I attempt to connect to an intranet web service from a web application
This is really bugging me. I'm using a GridView and want to format it
This is my attempt to make a menu with a fading background when the
I have text which has to be right aligned, and when this text takes
I would like to change the text style/ font size /font colour for my
This is my first attempt in exchanging values between 2 JSP pages, the index.jsp

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.