本文介绍了从右到左ListView遇到麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试绘制列标题,但是我已经绘制了它,但是当我将方向更改为从右到左时,列是不固定的,而是从左到右开始,这是一个问题将鼠标移到上方,我不知道为什么会发生这种情况
代码:
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);
}
}
}
推荐答案
这篇关于从右到左ListView遇到麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!