【Visual Studio 扩展工具】如何在ComponentOneFlexGrid树中显示RadioButton
概述
在ComponentOne Enterprise .NET控件集中,FlexGrid表格控件是用戶(hù)使用頻率最高的控件之一。它是一個(gè)功能強(qiáng)大的數(shù)據(jù)管理工具,輕盈且靈動(dòng),以分層的形式展示數(shù)據(jù)(數(shù)據(jù)呈現(xiàn)更加直觀)。
FlexGrid 簡(jiǎn)介
FlexGrid?是業(yè)界推崇的 .NET 數(shù)據(jù)表格,集成于 ComponentOne Enterprise .NET控件集中,可靈活、輕量、快速用于 WPF、WinForm、UWP、MVC、Silverlight、ActiveX平臺(tái)。
分層數(shù)據(jù)展示
在分層數(shù)據(jù)展示中,FlexGrid 可以使用Node.Checked屬性在任何節(jié)點(diǎn)行之前顯示CheckBox。 然后,父節(jié)點(diǎn)之前的這些復(fù)選框可用于添加功能,例如啟用/禁用或選擇/取消選擇樹(shù)中的所有子節(jié)點(diǎn)。
假設(shè)用戶(hù)想要利用RadioButton來(lái)代替這些復(fù)選框,并且,需要在對(duì)子節(jié)點(diǎn)進(jìn)行“選擇/取消”按鈕操作時(shí),同時(shí)影響父節(jié)點(diǎn)狀態(tài)的功能,利用 FlexGrid 數(shù)該如何實(shí)現(xiàn)?
是否有可能在樹(shù)中顯示單選按鈕?
答案是肯定的。 訣竅是使用 FlexGrid網(wǎng)格中子節(jié)點(diǎn)的Node.Image屬性顯示RadioButton圖像。
Node child = c1FlexGrid1.Rows.AddNode(1);
child.Image = Image.FromFile("../../Resources/Img_Unchecked.png");
我們剛剛展示了效果圖。 現(xiàn)在,我們需要在改變“選中/取消”父節(jié)點(diǎn)時(shí)同時(shí)影響子節(jié)點(diǎn)狀態(tài)。 為了滿(mǎn)足這一要求,FlexGrid 網(wǎng)格的CellChecked事件將是一個(gè)不錯(cuò)的選擇。當(dāng)用戶(hù)改變父節(jié)點(diǎn)當(dāng)前狀態(tài)時(shí),它會(huì)被觸發(fā)。
private void C1FlexGrid1_CellChecked(object sender, RowColEventArgs e) { //Get the checked/unchecked node row Node node = c1FlexGrid1.Rows[e.Row].Node; //If node row is itself a parent if (node.Parent == null) { //If checked if (node.Checked == CheckEnum.Checked) { //For each child row foreach(Node childNode in node.Nodes) { //Enabled childNode.Row.AllowEditing = true; childNode.Row.StyleNew.BackColor = Color.White; } } //If unchecked else if(node.Checked == CheckEnum.Unchecked) { //For each child row foreach (Node childNode in node.Nodes) { //Disabled childNode.Row.AllowEditing = false; childNode.Row.StyleNew.BackColor = Color.LightGray; } } } } 接下來(lái),如果通過(guò)網(wǎng)格的MouseDown事件中的代碼啟用了子節(jié)點(diǎn),它將處理單選按鈕的切換。
private void C1FlexGrid1_MouseDown(object sender, MouseEventArgs e) { HitTestInfo hti = c1FlexGrid1.HitTest(e.Location); //Get node row corresponding to clicked row Node node = c1FlexGrid1.Rows[hti.Row].Node; Rectangle cellBounds = c1FlexGrid1.GetCellRect(hti.Row, hti.Column); //If it is a child row if(node.Parent != null) { //Only for RadioButton if (hti.Column == 1 && node.Level == 1 && (hti.X >= cellBounds.X + 33) && (hti.X <= cellBounds.X + 43)) { //Check if enabled if(node.Row.AllowEditing) { //Currently unchecked if (Convert.ToInt32(node.Key) == 0) { //Checked state node.Image = Image.FromFile("../../Resources/Img_Checked.png"); node.Key = 1; } //Currently checked else { //Unchecked state node.Image = Image.FromFile("../../Resources/Img_Unchecked.png"); node.Key = 0; } } } } } 在上面的代碼中,我們?cè)贜ode.Key屬性中存儲(chǔ)二進(jìn)制狀態(tài):0表示未檢查狀態(tài),1表示已檢查狀態(tài)。
以上就是關(guān)于:如何在ComponentOne FlexGrid樹(shù)中顯示RadioButton的具體做法。與此同時(shí),如果需要顯示RadioButton以外的控件,ComponentOne 也同樣支持!
ComponentOne Enterprise?|?下載試用
ComponentOne是一款專(zhuān)注于企業(yè)應(yīng)用高性能開(kāi)發(fā)的 .NET 全功能控件套包,包含300余種控件,支持7大平臺(tái),涵蓋7大功能模塊。較于市面上其他同類(lèi)產(chǎn)品,ComponentOne更加輕盈,功能更加強(qiáng)大,20多年的開(kāi)發(fā)經(jīng)驗(yàn),將為您的應(yīng)用系統(tǒng)帶來(lái)更為安全的使用體驗(yàn)。純中文操作界面,一對(duì)一技術(shù)支持,廠(chǎng)商級(jí)的技術(shù)服務(wù),共同造就了這款國(guó)際頂級(jí)控件套包。
您對(duì)ComponentOne 產(chǎn)品的任何技術(shù)問(wèn)題,都有技術(shù)支持工程師提供1對(duì)1專(zhuān)業(yè)解答,點(diǎn)擊此處即可發(fā)帖提問(wèn)>>?技術(shù)支持論壇
轉(zhuǎn)載于:https://www.cnblogs.com/C1SupportTeam/p/10141826.html
總結(jié)
以上是生活随笔為你收集整理的【Visual Studio 扩展工具】如何在ComponentOneFlexGrid树中显示RadioButton的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
 
                            
                        - 上一篇: 中通快递多少钱一公斤啊?
- 下一篇: linux history记录格式修改
