回复 3楼Tomato的帖子
可以通过以下代码实现:
- public MainWindow()
- {
- InitializeComponent();
- List<Test> tests = new List<Test>();
- bool flag = true;
- for (int i = 0; i < 100; i++)
- {
- Test a = new Test();
- a.A = i.ToString();
- a.B = i.ToString();
- a.D = flag;
- flag = !flag;
- tests.Add(a);
- }
- fg.ItemsSource = tests;
- fg.SelectionMode = C1.WPF.FlexGrid.SelectionMode.Row;
- fg.PreviewMouseRightButtonDown += new MouseButtonEventHandler(fg_PreviewMouseRightButtonDown);
- }
- void fg_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
- {
- HitTestInfo hf = fg.HitTest(e);
- this.fg.Select(hf.Row, 0);
- }
- }
- public class Test
- {
- public string A { get; set; }
- public string B { get; set; }
- public bool D { get; set; }
- }
复制代码 |