找了半天不知道在哪设置!!
就是数据满行后自动换下一行显示!!怎么设置!!??
就是数据满行后自动换下一行显示!!怎么设置!!??
解决方案 »
- c#编写程序,实现双击文件名得到该文件的路径
- 在WINFORM中,设置了控件的AutoScroll属性为True, 但是,怎样让其内容,随着滚动条而滚动呢?
- 跨子域名,cookies共享遇到的问题!
- 用C#创建资源管理器左边的Explore tree容易吗?
- 高手帮忙!如何将数字转换成英文,在线等!
- Form.Location 赋值前后 值不一致??
- 呜呜...这段代码怎么改都改不正确.路过的好心人帮我看看.今晚弄不出来就挂了
- 如何在使用DLL文件后,通过程序卸载使用的DLL文件?
- 关于自定义控件的事件问题
- ListView 问题,如何在ListView中实现中文排序?
- 使用reflector出现"未将对象引用设置到对象的实例",求高人解决。
- 关于Visual Studio 2008 数据库
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Data;
using System.ComponentModel;
namespace Dobon.Samples.Forms
{
/// <summary>
///为了在DataGrid上表示改行字符串的DataGridColumnStyle
/// </summary>
public class DataGridTextBoxColumnEx : DataGridTextBoxColumn
{
//指定描绘文字列的Margin
Point _margin = new Point(1, 2);
//TypeConverter取得
private TypeConverter _typeConverter = null;
public override PropertyDescriptor PropertyDescriptor
{
set
{
base.PropertyDescriptor = value;
if (PropertyDescriptor != null &&
PropertyDescriptor.PropertyType != typeof(object))
{
_typeConverter =
System.ComponentModel.TypeDescriptor.GetConverter(
PropertyDescriptor.PropertyType);
}
}
}
// Paint对象重载
protected override void Paint(Graphics g,
Rectangle bounds,
CurrencyManager source,
int rowNum,
Brush backBrush,
Brush foreBrush,
bool alignToRight)
{
//取得表示的字符串
string text =
GetText(GetColumnValueAtRow(source, rowNum));
StringFormat sf = new StringFormat();
//指定配置
switch (this.Alignment)
{
case HorizontalAlignment.Left:
sf.Alignment = StringAlignment.Near;
break;
case HorizontalAlignment.Center:
sf.Alignment = StringAlignment.Center;
break;
case HorizontalAlignment.Right:
sf.Alignment = StringAlignment.Far;
break;
}
//指定文本的方向
if (alignToRight)
sf.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
//给背景涂颜色
g.FillRectangle(backBrush, bounds);
RectangleF rectf = new RectangleF(
bounds.X, bounds.Y, bounds.Width, bounds.Height);
rectf.Inflate(-_margin.X, -_margin.Y);
//文字列描绘
g.DrawString(text, DataGridTableStyle.DataGrid.Font,
foreBrush, rectf, sf);
sf.Dispose();
}
//返回表示的文字列
private string GetText(object val)
{
if ((val as DBNull) != null)
return NullText;
if (Format != null && Format.Length != 0 &&
(val as IFormattable) != null)
{
try
{
return ((IFormattable) val).ToString(
Format, FormatInfo);
}
catch
{
}
}
if (_typeConverter != null &&
_typeConverter.CanConvertTo(typeof(string)))
{
return (string) _typeConverter.ConvertTo(
val, typeof(string));
}
return (val != null ? val.ToString() : "");
}
}
}
return (string) _typeConverter.ConvertTo(
val, typeof(string));
}
return (val != null ? val.ToString() : "");
}
}
}
this.dataGridView1.RowsDefaultCellStyle.WrapMode = DataGridViewTriState.True;//换行
this.dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;//自动行高
foreach (DataGridViewColumn c in this.dataGridView1.Columns)
c.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader;//行动列宽
http://www.web521.com/design/P39/A073295.shtmlhttp://www.fish888.com/GridView-DataGrid-t118997
gridControl.DataMember=ds.Tables[0].TableName;
DevExpress.XtraEditors.Repository.RepositoryItemMemoEdit x=new DevExpress.XtraEditors.Repository.RepositoryItemMemoEdit();
gridView1.Columns[1].ColumnEdit=x;
gridView1.Columns[1].FiledName="内容";//绑定的字段
gridView1.Columns[1].Width=100;
gridView1.OptionsView.RowAutoHeight=true;