|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
datagridview multiselect without keyboard !howdy....
in a datagridview - the user can select multiple rows by holding the Control key down as they click with the mouse. I am looking for a way to achieve the same result without the use of the keyboard (I have a touchscreen application). any ideas? - I'm a bit stuck :) thanks, Oli. The easiest way might be to toggle rows as selected/unselected when they
click (touch) each row. -- Show quoteHide quoteBryan Phillips MCSD, MCDBA, MCSE Blog: http://bphillips76.spaces.live.com Web Site: http://www.composablesystems.net "olihar***@googlemail.com" <olihar***@googlemail.com> wrote in message news:1176803624.400390.122930@q75g2000hsh.googlegroups.com: > howdy.... > > in a datagridview - the user can select multiple rows by holding the > Control key down as they click with the mouse. > > I am looking for a way to achieve the same result without the use of > the keyboard (I have a touchscreen application). > > any ideas? - I'm a bit stuck :) > > thanks, > Oli. You can try tracking selected rows yourself and toggle the selections
on and off in the CellClick event. You can use the RowPrePaint event to set the backcolor of selected rows. //in form.load this.dataGridView1.DefaultCellStyle.SelectionBackColor = Color.FromArgb(0, Color.Black); //hide normal color this.dataGridView1.EditMode = DataGridViewEditMode.EditProgrammatically; this.dataGridView1.CurrentCell = null; this.dataGridView1.CellClick += new DataGridViewCellEventHandler(dataGridView1_CellClick); this.dataGridView1.RowPrePaint += new DataGridViewRowPrePaintEventHandler(dataGridView1_RowPrePaint); private List<int> selectedRowIndexes = new List<int>(); void dataGridView1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e) { if (this.selectedRowIndexes.IndexOf(e.RowIndex) > -1) dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.LightBlue; else dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = SystemColors.Window; } void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (this.selectedRowIndexes.IndexOf(e.RowIndex) > -1) this.selectedRowIndexes.Remove(e.RowIndex); else this.selectedRowIndexes.Add(e.RowIndex); this.dataGridView1.CurrentCell = null; } ================== Clay Burch Syncfusion, Inc.
Other interesting topics
Databind a nullable date to a masked textbox
Graphics dpi not correct This code compiles/runs but breaks designer... Adding an event handler to a dynamically populated control Datagridview help Problems with BackGroundWorker Newbie question: how to set focus to a usercontrol Login window vs Main window How to read Default Values from App.Config for User Settings? Forms and labels |
|||||||||||||||||||||||