Dev技巧
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 | 1.TextEditor(barEditItem) 取文本 string editValue = barEditItem1.EditValue.ToString(); // 错误,返回 null string editValue = ((DevExpress.XtraEditors.TextEdit)barEditItem).EditValue.ToString(); // 精确, 返回文本框内容 DevExpress 使用技巧 2.ComboBoxEdit(barEditItem) 添加 Item string item = "comboboxItem1" ; ((DevExpress.XtraEditors.Repository.RepositoryItemComboBox)this.barEditItem.Edi t).Items. Add (item); 3.ComboBoxEdit(barEditItem) 取文本 string itemValue = this.barEditItem.EditValue.ToString(); 4.Ribbon 控件 // 添加 Page DevExpress.XtraBars.Ribbon.RibbonPageribbonPage = new RibbonPage(); ribbonControl.Pages. Add (ribbonPage); // 添加 Group DevExpress.XtraBars.Ribbon.RibbonPageGroupribbonPageGroup = new RibbonPageGroup(); ribbonPage.Groups. Add (ribbonPageGroup); // 添加 Button DevExpress.XtraBars.BarButtonItembarButtonItem = new BarButtonItem(); ribbonPageGroup.ItemLinks. Add (barButtonItem); // 添加 barSubItem DevExpress.XtraBars.BarSubItembarSubItem = new BarSubItem(); ribbonPageGroup.ItemLinks. Add (barSubItem); //barSubItem 下添加 Button barSubItem.AddItem(barButtonItem); // 奇异的删除 Page 问题( DevExpress 使用技巧) while (this.ribbonControl.Pages. Count > 0) { ribbonControl.Pages.Remove(ribbonControl.Pages[0]); // 调试正常, 运转报异 常 } while (this.ribbonControl.Pages. Count > 0) { ribbonControl.SelectedPage = ribbonControl.Pages[0]; ribbonControl.Pages.Remove(ribbonControl.SelectedPage); // 运转正常 } // 遏止 F10 键 Tips ( DevExpress 使用技巧) ribbonControl.Manager.UseF10KeyForMenu = false ; //DX 按钮 ApplicationIcon 属性改动图标 右键 Add ApplicationMenu 添加 evExpress.XtraBars.Ribbon.ApplicationMenu5.HitInfo // 在 Tab 页上点击右键的工作响应( DevExpress 使用技巧) void xtraTabbedMdiManager_Event(object sender, MouseEventArgs e) { if (e.Button == MouseButtons. Right &&ActiveMdiChild != null ) { DevExpress.XtraTab.ViewInfo.BaseTabHitInfohInfo = xtraTabbedMdiManager.CalcHitInfo(e.Location); // 右键点击位置:在 Page 上且不在封闭按钮内 if (hInfo.IsValid&&hInfo.Page != null && !hInfo.InPageCloseButton) { this.popupMenu.ShowPopup(Control.MousePosition);// 在鼠标位置弹出, 而不是 e.Location } } } // 在 ribbon 上点击右键的工作响应 private void ribbonControl1_ShowCustomizationMenu(object sender, RibbonCustomizationMenuEventArgs e) { // 禁掉原系统右键菜单 e.ShowCustomizationMenu = false ; // 右键位置:在 barButtonItem 上 if (e.HitInfo != null &&e.HitInfo.InItem &&e.HitInfo.Item.Item is BarButtonItem) { this.popupMenu.ShowPopup(Control.MousePosition); } // 右键位置:在 barSubItem 中的 barButtonItem 上 else if (e.Link != null &&e.Link.Item != null &&e.Link.Item is BarButtonItem) { this.popupMenu.ShowPopup(Control.MousePosition); } } 6. 皮肤 // 添加皮肤轨范集后注册皮肤( DevExpress 使用技巧) DevExpress.UserSkins.OfficeSkins.Register(); DevExpress.UserSkins.BonusSkins.Register(); // 设置皮肤 DevExpress.LookAndFeel.UserLookAndFeel. Default .SetSkinStyle( "Liquid Sky" ); // 若皮肤称号错误则按系统默许设置(第一个皮肤) //GalleryFilterMenuPopup 工作设置弹出选择菜单的“ All Groups”为中文 private void rgbiSkins_GalleryFilterMenuPopup(object sender, GalleryFilterMenuEventArgs e) { e.FilterMenu.ItemLinks[n].Caption = " 一切皮肤 " ; //n= 分组数 +1 } //GalleryInitDropDownGallery 工作设置弹出皮肤列表的表头“ ALL Groups”为中文 private void rgbiSkins_GalleryInitDropDownGallery(object sender, InplaceGalleryEventArgs e) { e.PopupGallery.FilterCaption = " 一切皮肤 " ; } 7.dockManager 将视图的状况信息保管到 xml 文件 dockManager1.SaveLayoutToXml( "..\\UserConfig\\ViewInfo.xml" ); 导出 xml 中保管的状况信息 dockManager1.RestoreLayoutFromXml( "..\\UserConfig\\ViewInfo.xml" ); 8.barManager 设置 bar 的字体与系统字体 barAndDockingController1.AppearancesBar.ItemsFont = new Font(this.Font.FontFamily, currentFontSize); 9. 设置系统字体 DevExpress.Utils.AppearanceObject.DefaultFont = new Font(this.Font.FontFamily, currentFontSize); 10.treeView 为 tree 节点加右键菜单并选中该节点 private void treeList1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons. Right ) { DevExpress.XtraTreeList.TreeListHitInfo hi = treeList1.CalcHitInfo(e.Location); if (hi.Node != null &&hi.Node.ImageIndex == 5) // 叶子节点的 ImageIndex == 5 { TreeListNode node = treeList1.FindNodeByID(hi.Node.Id); treeList1.FocusedNode = node; this.popupMenu1.ShowPopup(MousePosition); } } } |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步