Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
i was trying to draw column header and i have already drawn it but there's an issue when i change the direction into right to left , the columns is not fixed and it starts from left to right and it's moving on mouse over and i dunno why is this happening

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics.CodeAnalysis;
using System.Windows.Forms.VisualStyles;
using System.Drawing.Drawing2D;
using System.Globalization;

namespace WindowsFormsApplication10
{
    public partial class Form2 : Form
    {
        Font drawFont = new Font("Tahoma", 9,FontStyle.Bold);
        StringFormat Format = new StringFormat(StringFormatFlags.DirectionRightToLeft);
        
        public Form2()
        {
            InitializeComponent();
        }
        void onDrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
        {
            Format.LineAlignment = StringAlignment.Center;
            Format.Alignment = StringAlignment.Center;
            e.Graphics.FillRectangle(Brushes.LightSteelBlue, e.Bounds);
            e.Graphics.DrawString(e.Header.Text, Font, Brushes.Black, e.Bounds, Format);
        }
}
}
Posted
Updated 18-Jul-11 10:29am
v2

1 solution

ListView is a tricky and, at least out of the box, limited component. Try using this one.

A Much Easier to Use ListView[^]

Hope this helps!

Cheers!
 
Share this answer
 
Comments
snake1 18-Jul-11 16:12pm    
it's useful and it's so amazing but the right to left is so annoying
i just want to change the direction of the columns to be right to left without any troubles , when i try to do that with your sample it's the same thing the columns invisible and visible again and some annoying things happens to me
anyway to solve this problem?

Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900