从blog.org的我的原博客中迁入
发表时间:2006-9-13 9:15:45
public MyForm()
{
...
_riCityTypeLookUpEdit = new DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit();
DataSet ds = DatabaseManager.PrepareDataSet(this);
// Датасет состоит из двух таблиц: населенные пункты (1) и их типы (2).
// Грид имеет примерно такой вид (на экране):
// +--------------+----------+
// | Нас. пункт | Тип |
// +--------------+----------+
// | Москва | Город | <- это "комбобокс" (точнее LookUpEdit),
// +--------------+----------+ в который попадают данные из таблицы "CityTypeRf"
_gridControl.DataMember = "CityRf";
_gridControl.DataSource = ds;
// Тип населенного пункта
_riCityTypeLookUpEdit.NullText = "[нет]";
_riCityTypeLookUpEdit.DataSource = ds.Tables["CityTypeRf"];
_riCityTypeLookUpEdit.DisplayMember = "NAME";
_riCityTypeLookUpEdit.Columns.AddRange(new DevExpress.XtraEditors.Controls.LookUpColumnInfo[] {
new DevExpress.XtraEditors.Controls.LookUpColumnInfo("NAME", "Наименование", -1),
new DevExpress.XtraEditors.Controls.LookUpColumnInfo("SHORT_NAME", "Сокращение", -1)
});
_gridView.Columns["TYPE_ID"].ColumnEdit = _riCityTypeLookUpEdit;
}
_gridControl.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] {
_riCityTypeLookUpEdit
});
======================================================
在gridview中怎样自动弹出编辑控件
How to automatically open the popup window of a dropdown in-place editor
Article ID: A1490 ; Product Group: .NET ; Product: XtraGrid ; Version(s): 2, 3, 6.x ; Modified On: 7 Sep 2006
Description
What is the best way to automatically show the popup list of a LookUp editor within a GridView?
Solution
You should handle the GridView.ShownEditor event and call the ShowPopup method against the GridView.ActiveEditor object. Below is the necessary code. Additionally, it's necessary to set the EditorShowMode option of the GridView.OptionsBehavior property to MouseUp.
[C#]
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Grid;
private void gridView1_ShownEditor(object sender, System.EventArgs e) {
GridView view = sender as GridView;
if(view.ActiveEditor is LookUpEdit) {
((LookUpEdit)view.ActiveEditor).ShowPopup();
throw new DevExpress.Utils.HideException();
}
===========================================
Getting the ComboBoxItem in a RepositoryItemComboBox
5 msg [devexpress.public.dotnet.xtraeditors]
--------------------------------------------------------------------------------
Getting the ComboBoxItem in a RepositoryItemComboBox
Oliver [Jul 13 2002, 00:31]
Hi there,
I want to get the "ComboBoxItem" after a User selected a value in a
"RepositoryItemComboBox".
It is very easy to do this with a original Windows ComboBox. I'm sure there
is also a easy way to do this in a RepositoryItemComboBox.
Who can help me?
//Windows ComboBox
Class1 x = (Class1) comboBox1.SelectedItem;
MessageBox.Show(x.MyValue.ToString());
//RepositoryItem ComboBox
Class1 x = (Class1) comboBox1.Properties.Items. ???
答:
You can, if it is active (see ActiveEditor).
If it is not active then (AFAIK) you'll find your value using cell value.
===============================================================
How to reorder XtraTreeList nodes through drag-and-dropArticle ID: A342 ; Product Group: .NET ; Product: XtraTreeList ; Version(s): 1, 6.x ; Modified On: 11 Sep 2006 DescriptionHow to Reorder XtraTreeList Nodes through Drag&DropSolutionThe attached sample projects demonstrate how to override the default drag&drop handling in an unbound XtraTreeList and allow users to reorder nodes only within a given parent node.The TreeList has the automatic drag&drop support. You can utilize it without having to write additional code. However, some tasks may require you to have control over drag&drop operations. Fortunately, the TreeList provides you with the necessary tools for accomplishing such tasks.You should use the DragOver event and change the e.Effect parameter, if you need to conditionally enable/disable the drop operation. Set e.Effect to DragDropEffects.None to disable the drop operation. The DragDrop event will not be fired in this case.The DragDrop event is used to handle dropping an object at a given position. Our sample project utilizes it to move a node to a new location via the SetNodeIndex method of the TreeList class. Finally, the e.Effect parameter should be set to DragDropEffects.None to notify the TreeList of that the drag&drop operation is handled and the default processing is not needed.To calculate a value for e.Effect, you may need to know which node resides under the mouse cursor. You should use the GetHitInfo method of TreeList for this. Please note that screen coordinates are passed to the DragOver and DragDrop events. Before you can call GetHitInfo, you must convert screen coordinates to the TreeList coordinates via the the PointToClient method.[C#]
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Nodes;
private void treeList1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) {
TreeListNode dragNode, targetNode;
TreeList tl = sender as TreeList;
Point p = tl.PointToClient(new Point(e.X, e.Y));
dragNode = e.Data.GetData(typeof(TreeListNode)) as TreeListNode;
targetNode = tl.CalcHitInfo(p).Node;
tl.SetNodeIndex(dragNode, tl.GetNodeIndex(targetNode));
e.Effect = DragDropEffects.None;
}
============================================================
How to insert a TreeList node into a specific positionArticle ID: A1042 ; Product Group: .NET ; Product: XtraTreeList ; Version(s): 1 ; Modified On: 5 Dec 2005 DescriptionIs it possible to insert a node into the tree above/below a specific child node rather than just append it to the end of the child collection?SolutionYes, this is possible. You should use two methods to do this:A) Create a node via the TreeList.AppendNode method;B) move the node to the desired index within its parent via the TreeList.SetNodeIndex method.[C#]
using DevExpress.XtraTreeList.Nodes;
TreeListNode parentNode = treeList1.Nodes[0];
// insert a new node as the first child within its parent
TreeListNode newNode = treeList1.AppendNode(new object[] {"New first child"}, parentNode);
treeList1.SetNodeIndex(newNode, 0);
============================================================
devexpress.public.dotnet.xtraeditorsHistory/Archiviotextedit to show time2 msg [devexpress.public.dotnet.xtraeditors] --------------------------------------------------------------------------------textedit to show timePenk [Oct 20 2005, 07:26]I'm using a textedit to show the time of an entry that is stored in a
database, and its field has datetime format. How can I show only the time? I
tried to put in the format string: HH:mm, but don't works. Is this wrong?
Thanks.
Re: textedit to show timeTomas [Oct 21 2005, 15:33]MaskType = DevExpress.XtraEditors.Mask.MaskType.DateTime;
EditMask = "T";