翻譯|使用教程|編輯:龔雪|2025-07-10 10:45:30.300|閱讀 124 次
概述:本文主要介紹如何使用DevExpress WPF Grid控件檢查節(jié)點(diǎn),歡迎下載最新版組件體驗(yàn)!
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
DevExpress WPF擁有120+個(gè)控件和庫,將幫助您交付滿足甚至超出企業(yè)需求的高性能業(yè)務(wù)應(yīng)用程序。通過DevExpress WPF能創(chuàng)建有著強(qiáng)大互動(dòng)功能的XAML基礎(chǔ)應(yīng)用程序,這些應(yīng)用程序?qū)W⒂诋?dāng)代客戶的需求和構(gòu)建未來新一代支持觸摸的解決方案。 無論是Office辦公軟件的衍伸產(chǎn)品,還是以數(shù)據(jù)為中心的商業(yè)智能產(chǎn)品,都能通過DevExpress WPF控件來實(shí)現(xiàn)。
DevExpress技術(shù)交流群11:749942875 歡迎一起進(jìn)群討論
用戶可以將復(fù)選框嵌入到節(jié)點(diǎn)中,并允許最終用戶選中/取消選中它們:
1. 將屬性設(shè)置為true來顯示嵌入到節(jié)點(diǎn)中的復(fù)選框。
2. 設(shè)置復(fù)選框的值,執(zhí)行下列之一的操作:
下面的代碼示例展示了如何顯示復(fù)選框并將它們綁定到OnVacation字段:
Xaml
<dxg:GridControl Name="gridControl"> <dxg:GridControl.Columns> <dxg:GridColumn FieldName="Name"/> <dxg:GridColumn FieldName="Department"/> <dxg:GridColumn FieldName="Position"/> </dxg:GridControl.Columns> <dxg:GridControl.View> <dxg:TreeListView KeyFieldName="ID" ParentFieldName="ParentID" AutoExpandAllNodes="True" ShowCheckboxes="True" CheckBoxFieldName="OnVacation" /> </dxg:GridControl.View> </dxg:GridControl>
C#
public class Employee {
public int ID { get; set; }
public int ParentID { get; set; }
public string Name { get; set; }
public string Position { get; set; }
public string Department { get; set; }
public bool OnVacation { get; set; }
}
VB.NET
Public Class Employee Public Property ID As Integer Public Property ParentID As Integer Public Property Name As String Public Property Position As String Public Property Department As String Public Property OnVacation As Boolean End Class
注意:在您聚焦另一行之前,TreeListView不會(huì)發(fā)布被聚焦行的復(fù)選框值。要使TreeListView post復(fù)選框立即有值,請(qǐng)將屬性設(shè)置為true。
使用以下成員在代碼中選中/取消選中節(jié)點(diǎn):
當(dāng)節(jié)點(diǎn)的檢查狀態(tài)改變時(shí),TreeListView會(huì)引發(fā)事件,使用屬性來標(biāo)識(shí)節(jié)點(diǎn)是否被檢查。
將屬性設(shè)置為true,允許最終用戶將節(jié)點(diǎn)的復(fù)選框設(shè)置為三種狀態(tài)當(dāng)中的一個(gè)(選中,未選中或不確定):
TIP:在這種情況下,用戶可以指定一個(gè)復(fù)選框的狀態(tài),而不管它的父和子的狀態(tài)。
TreeListNode.IsChecked屬性返回以下值:
設(shè)置屬性為true,如果您想讓控件根據(jù)子節(jié)點(diǎn)和父節(jié)點(diǎn)的選擇自動(dòng)更新檢查狀態(tài):
使用以下屬性將復(fù)選框的啟用狀態(tài)綁定到屬性:
注意:屬性優(yōu)先于屬性。
下面的代碼示例展示了如何將復(fù)選框的啟用狀態(tài)綁定到Enabled字段:
Xaml
<dxg:GridControl Name="gridControl"> <dxg:GridControl.Columns> <dxg:GridColumn FieldName="Name"/> <dxg:GridColumn FieldName="Department"/> <dxg:GridColumn FieldName="Position"/> </dxg:GridControl.Columns> <dxg:GridControl.View> <dxg:TreeListView KeyFieldName="ID" ParentFieldName="ParentID" AutoExpandAllNodes="True" ShowCheckboxes="True" CheckBoxFieldName="OnVacation" IsCheckBoxEnabledFieldName="Enabled" /> </dxg:GridControl.View> </dxg:GridControl>
C#
public class Employee {
public int ID { get; set; }
public int ParentID { get; set; }
public string Name { get; set; }
public string Position { get; set; }
public string Department { get; set; }
public bool OnVacation { get; set; }
public bool Enabled { get; set; }
}
VB.NET
Public Class Employee Public Property ID As Integer Public Property ParentID As Integer Public Property Name As String Public Property Position As String Public Property Department As String Public Property OnVacation As Boolean Public Property Enabled As Boolean End Class
更多產(chǎn)品資訊及授權(quán),歡迎來電咨詢:023-68661681
慧都是?家?業(yè)數(shù)字化解決?案公司,專注于軟件、?油與?業(yè)領(lǐng)域,以深?的業(yè)務(wù)理解和?業(yè)經(jīng)驗(yàn),幫助企業(yè)實(shí)現(xiàn)智能化轉(zhuǎn)型與持續(xù)競(jìng)爭(zhēng)優(yōu)勢(shì)。
慧都是DevExpress的中國(guó)區(qū)的合作伙伴,DevExpress作為用戶界面領(lǐng)域的優(yōu)秀產(chǎn)品,幫助企業(yè)高效構(gòu)建權(quán)限管理、數(shù)據(jù)可視化(如網(wǎng)格/圖表/儀表盤)、跨平臺(tái)系統(tǒng)(WinForms/ASP.NET/.NET MAUI)及行業(yè)定制解決方案,加速開發(fā)并強(qiáng)化交互體驗(yàn)。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@ke049m.cn
文章轉(zhuǎn)載自:慧都網(wǎng)