DevExpress TreeList Common Problem Solutions
- 2021-11-24 02:40:20
- OfStack
1. How to add pictures to nodes? First, you need to add a picture control, then add a picture to it, and finally bind the node picture attribute of TreeList with the picture control. The code is as follows:
ImageList imagelist;
private void Test window _Load(object sender, EventArgs e)
{
con.ConnectionString = sqlconstr;
DataTable dt = new DataTable;
dt.Columns.Add(" Process ");
dt.Rows.Add("123");
treeList1.Dock = DockStyle.Fill;
treeList1.DataSource = dt;
imagelist = new ImageList;
imagelist.Images.Add(Image.FromFile(@"E:\ Picture material \2.jpg"));
treeList1.SelectImageList = imagelist;
treeList1.Nodes[0].ImageIndex = 0;
}
2. How do I set the background color to transparent?
treeList1.BackColor = Color.Transparent;
treeList1.Appearance.Empty.BackColor = Color.Transparent;
treeList1.Appearance.Row.BackColor = Color.Transparent;
3. How do I expand the current node and parent node?
/// <summary>
/// Expand the current node and parent node
/// </summary>
/// <param name="_node">
public void ParentNodeExpend(TreeListNode _node)
{
TreeListNode _cNode = _node;
treeList1..Nodes.TreeList.FindNodeByID(_cNode.Id).Expanded = true;
4. How to set the display horizontal scroll bar?
public void TreeListHorzScroll(TreeList treeList)
{
treeList.OptionsView.AutoWidth = false;
Let's take a look at the solutions to DevExpress common problems
layoutControl:
1. lookAndFeel.
2. OptionsView's AllowHotTrack "Put the mouse on to change color" and DrawItemBorders "Whether the control border is displayed"
3. BeginInvoke (new MethodInvoker (delegate {textEdit1.Focus ()}); "Getting the Focus"
4. layoutControl1.OptionsItemText.TextAlignMode=AlignInLayoutControl. (After setting the drag-and-drop control, the control automatically adjusts to the original content) View the picture
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
GridView:
1. Attribute IndicatorWidth, set the left-most column width of GirdView "automatically generate columns, which have nothing to do with bound data columns".
2. Disable sorting per column, this. gridView1.OptionsCustomization. AllowSort = false;
---------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
TreeList:
1. Disable sorting for each column and set OptionsColumn. AllowSort = false for each column, which can be seen in each column of Run Designer;
DateEdit:
1. Disable mouse scrolling.
dateEdit1.Spin += new DevExpress.XtraEditors.Controls.SpinEventHandler(dateEdit1_Spin);
void dateEdit1_Spin(object sender, DevExpress.XtraEditors.Controls.SpinEventArgs e)
{
e.Handled = true;
}