這篇文章主要介紹了如何使用ComponentOne提高.NET DataMap中的加載速度,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
FlexGrid for WinForm 采用了最新的數據綁定技術,并與Microsoft .NET Framework無縫集成。 因此,您可以獲得易于使用的靈活網格控件,用于創建用戶友好界面,以顯示、編輯、格式化、組織、匯總和打印表格數據。
FlexGrid的DataMap屬性允許您實現“已翻譯”的行或列。在轉換的行或列中,網格不顯示存儲在單元格中的值。相反,它會在列的DataMap中查找這些值并顯示映射的值。
有時您可能需要在C1FlexGrid / C1FlexGridClassic中使用DataMap來顯示項目列表。即使列表包含大量數據,其加載也是平滑且即時的。在本文中,我們將討論如何使用自定義ComboBox編輯器以加快DataMap網格的加載時間。
所有內置網格編輯器都實現IC1EmbeddedEditor接口,ComponentOne Input庫中的控件也是如此。 如果我們想要使用帶有C1FlexGrid的第三方編輯器,我們需要創建一個派生類并實現此接口。
創建一個模型類MyComboItem來綁定ComboBox。
public class MyComboItem
{
public int Id { get; set; }
public string Display { get; set; }}創建一個自定義控件MyComboBox,它繼承ComboBox類并實現IC1EmbeddedEditor接口。
public partial class MyComboBox : ComboBox, IC1EmbeddedEditor {
public MyComboBox()
{
InitializeComponent();
}
#region IC1EmbeddedEditor-Members // Initialize editor: select transferred value
public void C1EditorInitialize(object value, IDictionary editorAttributes)
{
this.SelectedValue = value;
}
//Get value from editor
public object C1EditorGetValue()
{
return (base.SelectedItem as MyComboItem)?.Id;
}
//Value is always TRUE
public bool C1EditorValueIsValid()
{
return true;
}
//Adjust editor size
public void C1EditorUpdateBounds(Rectangle rc)
{
if (rc.Height != -1 && rc.Width != -1)
{
this.Location = new Point(rc.X, rc.Y);
this.Width = rc.Width;
this.Height = this.DefaultSize.Height;
}
else
{
//Editor has scrolled out of the picture. Take over the height / width of -1.
this.Width = -1;
this.Height = -1;
}
}
//TRUE if Escape or Enter
public bool C1EditorKeyDownFinishEdit(KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape || e.KeyCode == Keys.Enter)
return true;
return false;
}
//Format and editor value
public string C1EditorFormat(object value, string mask)
{
return null;
}
//Style of Editors
public UITypeEditorEditStyle C1EditorGetStyle()
{
return UITypeEditorEditStyle.DropDown;
}
#endregion }}創建MyComboBox類的實例,并將其分配給網格的列編輯器,如下所示:
Dictionary<int, string> DMap = new Dictionary<int, string>(); ComboBox c1 = new MyComboBox(); List<MyComboItem> _list = new List<MyComboItem>(); c1.DataSource = _list; c1.ValueMember = "Id"; c1.DisplayMember = "Display"; _flex.Cols[2].Editor = c1; _flex.Cols[2].DataMap = DMap; //use DataMap to show IDs as values.
感謝你能夠認真閱讀完這篇文章,希望小編分享的“如何使用ComponentOne提高.NET DataMap中的加載速度”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,更多相關知識等著你來學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。