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 6765815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:45:24+00:00 2026-05-26T14:45:24+00:00

I have a WinForms application that is being used on tablet PC’s with touch

  • 0

I have a WinForms application that is being used on tablet PC’s with touch screens. The application is developed with Visual Studio 2008 and used version 3.5 of the .Net framework. I have had a request from a left-handed client to put the scrollbar of the ComboBoxes on the left-hand side of the dropdown area rather than the right, but I am not sure how to do this, or if it is even possible to do. Has anyone done this before or know how it can be done?

  • 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-05-26T14:45:25+00:00Added an answer on May 26, 2026 at 2:45 pm

    There is a solution here using Win32 API calls for modifying the ComboBox: http://www.codeguru.com/csharp/csharp/cs_controls/custom/print.php/c15261

    About halfway down, below the ‘Aligning ComoBox Objects’ heading.

    There is also a link to some sample code at the end of the page.


    Example – Left scrollbar & left text

    using System;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    
    namespace ComboBoxMod
    {
        static class Program
        {
            /// <summary>
            /// The main entry point for the application.
            /// </summary>
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new frmMain());
            }
        }
    
        public partial class frmMain : Form
        {
            private ComboBoxMod.ComboBox cbTest; //this is the modified combo box
            private System.Windows.Forms.Button btnToggleAlign;
            private System.ComponentModel.IContainer components = null;
    
            public frmMain()
            {
                this.cbTest = new ComboBoxMod.ComboBox();
                this.btnToggleAlign = new Button();
    
                InitialiseComponent();
    
                for (int i = 0; i < 50; i++)
                {
                    cbTest.Items.Add(i);
                }
            }
    
            void btnToggleAlign_Click(object sender, EventArgs e)
            {
                if (this.cbTest.ScrollAlignment == ComboBox.Alignment.Right) //If Right Aligned
                {
                    this.cbTest.ScrollAlignment = ComboBox.Alignment.Left; //Set To Left
                }
                else
                {
                    this.cbTest.ScrollAlignment = ComboBox.Alignment.Right; //Set To Right
                }
            }
    
            private void InitialiseComponent()
            {
                this.SuspendLayout();
    
                this.cbTest.FormattingEnabled = true;
                this.cbTest.Location = new System.Drawing.Point(12, 12);
                this.cbTest.Name = "cbTest";
                this.cbTest.Size = new System.Drawing.Size(180, 21);
                this.cbTest.TabIndex = 0;
    
                this.btnToggleAlign.Location = new System.Drawing.Point(12, 42);
                this.btnToggleAlign.Name = "btnScrollAlign";
                this.btnToggleAlign.Size = new System.Drawing.Size(180, 23);
                this.btnToggleAlign.TabIndex = 0;
                this.btnToggleAlign.Text = "Toggle Scrollbar Alignment";
                this.btnToggleAlign.UseVisualStyleBackColor = true;
                this.btnToggleAlign.Click += new EventHandler(btnToggleAlign_Click);
    
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(200, 75);
    
                this.Controls.Add(this.cbTest);
                this.Controls.Add(this.btnToggleAlign);
    
                this.Name = "frmMain";
                this.Text = "frmMain";
                this.ResumeLayout(false);
            }
    
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }
        }
    
        public class ComboBox : System.Windows.Forms.ComboBox //Inherits ComboBox
        {
            [DllImport("user32", CharSet = CharSet.Auto)]
            public extern static int GetWindowLong(IntPtr hwnd, int nIndex); //Retrieve Info About Specified Window
    
            [DllImport("user32")]
            public static extern int SetWindowLong(IntPtr hwnd, int nIndex, int dwNewLong); //Change An Attribute Of Specified Window
    
            [DllImport("user32.dll")]
            public static extern int GetComboBoxInfo(IntPtr hWnd, ref COMBOBOXINFO pcbi); //Retrieve Info About Specified Combo Box
    
    
            [StructLayout(LayoutKind.Sequential)]
            public struct COMBOBOXINFO //Contains ComboBox Status Info
            {
                public Int32 cbSize;
                public RECT rcItem;
                public RECT rcButton;
                public ComboBoxButtonState caState;
                public IntPtr hwndCombo;
                public IntPtr hwndEdit;
                public IntPtr hwndList;
            }
    
    
            [StructLayout(LayoutKind.Sequential)] //Describes Width, Height, And Location Of A Rectangle
            public struct RECT
            {
                public int Left;
                public int Top;
                public int Right;
                public int Bottom;
            }
    
            public enum ComboBoxButtonState //Determines Current State Of ComboBox
            {
                STATE_SYSTEM_NONE = 0,
                STATE_SYSTEM_INVISIBLE = 0x00008000,
                STATE_SYSTEM_PRESSED = 0x00000008
            }
    
            /// <summary> 
            /// Alignment Enum For Left & Right
            /// </summary> 
            public enum Alignment
            {
                Left = 0,
                Right = 1
            }
    
            /// <summary> 
            /// Align ScrollBar 
            /// </summary> 
            public Alignment ScrollAlignment
            {
                get
                {
                    return Scroll; //Get Value
                }
                set
                {
                    if (Scroll == value) //If Not Valid Value
                        return;
    
                    Scroll = value; //Set Value
                    AlignScrollbar(); //Call AlignScroll Method
                }
            }
    
            private const int GWL_EXSTYLE = -20; //ComboBox Style
            private const int WS_EX_RIGHT = 4096; //Right Align Text 
            private const int WS_EX_LEFTSCROLLBAR = 16384; //Left ScrollBar
            private const int WS_EX_RIGHTSCROLLBAR = 128; //Right ScrollBar
    
            private IntPtr handle; //Handle Of ComboBox
            private Alignment Scroll; //Alignment Options For ScrollBar
    
    
            public ComboBox()
            {
                handle = CASGetHandle(this); //Get Handle Of ComboBox
                Scroll = Alignment.Right; //default alignment
            }
    
            /// <summary>
            /// Retrieves ComboBox Handle
            /// </summary>
            /// <param name="CASCombo"></param>
            /// <returns></returns>
            public IntPtr CASGetHandle(ComboBox CASCombo)
            {
    
                COMBOBOXINFO CASCBI = new COMBOBOXINFO(); //New ComboBox Settings Object
                CASCBI.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(CASCBI); //Call In Correct Size
                GetComboBoxInfo(CASCombo.Handle, ref CASCBI); //Obtain Handle
                return CASCBI.hwndList; //Return Handle
            }
    
            /// <summary>
            /// Align The ComboBox ScrollBar
            /// </summary>
            private void AlignScrollbar()
            {
                if (handle != IntPtr.Zero) //If Valid Handle
                {
                    int style = GetWindowLong(handle, GWL_EXSTYLE); //Get ComboBox Style
                    switch (Scroll)
                    {
                        case Alignment.Left:
                            style = WS_EX_LEFTSCROLLBAR; //Align ScrollBare To The Left
                            break;
                        case Alignment.Right:
                            style =  WS_EX_RIGHTSCROLLBAR; //Align ScrollBare To The Right
                            break;
                    }
                    SetWindowLong(handle, GWL_EXSTYLE, style); //Apply On ComboBox
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Winforms application created in Visual Studio 2005 Pro, it connects to
I have a WinForms Form that used to be a standalone application, but is
I have a winforms application that normally is at about 2-4% CPU. We are
I have C# winforms application that needs to start an external exe from time
I have a winforms application that presently ships with a chm file for context-sensitive
I have a winforms application that is doing the following: on each query: Db
I have an winforms application that was built using MVC. The controller is subscribing
I have a Winforms application that generates its own PrintDocument object for printing. It
We have a WinForms application that uses SQL server to store its data. To
I have a desktop (winforms) application that uses a Firebird database as a data

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.