Click here to Skip to main content
15,927,060 members
Home / Discussions / C#
   

C#

 
JokeRe: Coding Standard Question Pin
Pete O'Hanlon1-Oct-07 21:59
mvePete O'Hanlon1-Oct-07 21:59 
GeneralRe: Coding Standard Question Pin
Scott Dorman2-Oct-07 2:59
professionalScott Dorman2-Oct-07 2:59 
GeneralRe: Coding Standard Question Pin
Robert Rohde2-Oct-07 1:55
Robert Rohde2-Oct-07 1:55 
GeneralRe: Coding Standard Question Pin
Scott Dorman2-Oct-07 3:01
professionalScott Dorman2-Oct-07 3:01 
GeneralRe: Coding Standard Question Pin
PIEBALDconsult2-Oct-07 5:41
mvePIEBALDconsult2-Oct-07 5:41 
QuestionSelecting listview item by method not retained when tabbing into listview Pin
jchalfant1-Oct-07 9:30
jchalfant1-Oct-07 9:30 
AnswerRe: Selecting listview item by method not retained when tabbing into listview Pin
jchalfant1-Oct-07 9:59
jchalfant1-Oct-07 9:59 
Questioncalling modeless lookup form from datagridview combobox Pin
AndrusM1-Oct-07 9:29
AndrusM1-Oct-07 9:29 
I tried to use modeless lookup form for DataGridView custom ComboBoxColumn without success.

Steps to reproduce issue:

1. Run code
2. Enter some character
3. Press Tab

Observed:

1. Next row receives focus
2. Current form remains active

Expected:

1. Focus should remain in current combobox.
2. Lookup form must become active form.

How to fix ?

Andrus.

using System;<br />
using System.Windows.Forms;<br />
<br />
class ComboBoxColumn : DataGridViewComboBoxColumn {<br />
}<br />
<br />
class ComboBoxCell : DataGridViewComboBoxCell {<br />
<br />
public override Type EditType {<br />
<br />
get {<br />
return typeof(ComboBoxEditingControl);<br />
}<br />
}<br />
<br />
}<br />
<br />
class ComboBoxEditingControl : MyComboBox, IDataGridViewEditingControl {<br />
<br />
protected int rowIndex;<br />
protected DataGridView dataGridView;<br />
protected bool valueChanged = false;<br />
<br />
protected override void OnTextChanged(EventArgs e) {<br />
<br />
base.OnTextChanged(e);<br />
NotifyDataGridViewOfValueChange();<br />
}<br />
<br />
protected virtual void NotifyDataGridViewOfValueChange() {<br />
this.valueChanged = true;<br />
<br />
if (this.dataGridView != null) {<br />
this.dataGridView.NotifyCurrentCellDirty(true);<br />
}<br />
<br />
}<br />
<br />
public Cursor EditingPanelCursor {<br />
<br />
get {<br />
return Cursors.IBeam;<br />
}<br />
<br />
}<br />
<br />
public DataGridView EditingControlDataGridView {<br />
get {<br />
return this.dataGridView;<br />
}<br />
<br />
set {<br />
this.dataGridView = value;<br />
}<br />
}<br />
<br />
public object EditingControlFormattedValue {<br />
<br />
set {<br />
<br />
if (value.ToString() != this.Text) {<br />
<br />
this.Text = value.ToString();<br />
<br />
NotifyDataGridViewOfValueChange();<br />
<br />
}<br />
<br />
}<br />
<br />
get {<br />
<br />
return this.Text;<br />
<br />
}<br />
<br />
}<br />
<br />
public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts <br />
context) {<br />
<br />
return this.Text;<br />
<br />
}<br />
<br />
<br />
<br />
public void PrepareEditingControlForEdit(bool selectAll) {<br />
<br />
}<br />
<br />
public bool RepositionEditingControlOnValueChange {<br />
<br />
get {<br />
return false;<br />
}<br />
}<br />
<br />
public int EditingControlRowIndex {<br />
<br />
get {<br />
return rowIndex;<br />
}<br />
<br />
set {<br />
this.rowIndex = value;<br />
}<br />
}<br />
<br />
public void ApplyCellStyleToEditingControl(DataGridViewCellStyle <br />
dataGridViewCellStyle) {<br />
DropDownStyle = ComboBoxStyle.DropDown;<br />
}<br />
<br />
public bool EditingControlWantsInputKey(Keys keyData, bool <br />
dataGridViewWantsInputKey) {<br />
return !dataGridViewWantsInputKey;<br />
}<br />
<br />
public bool EditingControlValueChanged {<br />
<br />
get {<br />
return valueChanged;<br />
}<br />
<br />
set {<br />
valueChanged = value;<br />
}<br />
}<br />
<br />
<br />
<br />
public class Form1 : Form {<br />
<br />
private DataGridView dataGridView1 = new myDataGridView();<br />
<br />
[STAThread]<br />
public static void Main() {<br />
try {<br />
Application.Run(new Form1());<br />
}<br />
catch (Exception e) {<br />
MessageBox.Show(e.ToString());<br />
}<br />
}<br />
<br />
public Form1() {<br />
this.Controls.Add(this.dataGridView1);<br />
this.Load += new EventHandler(Form1_Load);<br />
}<br />
<br />
private void Form1_Load(object sender, EventArgs e) {<br />
<br />
ComboBoxColumn comboBoxColumn = new ComboBoxColumn();<br />
ComboBoxCell ComboBoxCell = new ComboBoxCell();<br />
comboBoxColumn.CellTemplate = ComboBoxCell;<br />
dataGridView1.Columns.Add(comboBoxColumn);<br />
}<br />
}<br />
}<br />
<br />
public class MyComboBox : ComboBox {<br />
<br />
protected override void OnValidating(System.ComponentModel.CancelEventArgs <br />
e) {<br />
<br />
e.Cancel = true;<br />
base.OnValidating(e);<br />
Form f = new Form();<br />
f.Text = "Modeless lookup form";<br />
f.Show();<br />
}<br />
}<br />
<br />
public class myDataGridView : DataGridView {<br />
<br />
protected override void OnDataError(bool displayErrorDialogIfNoHandler, <br />
DataGridViewDataErrorEventArgs e) {<br />
e.Cancel = false;<br />
}<br />
}


Andrus

QuestionInsert a row in Gridview Pin
ss.mmm1-Oct-07 9:24
ss.mmm1-Oct-07 9:24 
AnswerRe: Insert a row in Gridview Pin
Not Active1-Oct-07 9:46
mentorNot Active1-Oct-07 9:46 
GeneralRe: Insert a row in Gridview Pin
ss.mmm1-Oct-07 9:55
ss.mmm1-Oct-07 9:55 
GeneralRe: Insert a row in Gridview Pin
Not Active1-Oct-07 10:05
mentorNot Active1-Oct-07 10:05 
GeneralRe: Insert a row in Gridview Pin
DotNetXenon1-Oct-07 10:12
DotNetXenon1-Oct-07 10:12 
GeneralRe: Insert a row in Gridview Pin
ss.mmm15-Oct-07 8:28
ss.mmm15-Oct-07 8:28 
QuestionUniversal Toolbox Item installation help Pin
Jason Farrar1-Oct-07 9:06
Jason Farrar1-Oct-07 9:06 
AnswerRe: Universal Toolbox Item installation help Pin
TJoe1-Oct-07 13:10
TJoe1-Oct-07 13:10 
QuestionMSMQ Triggers Pin
Not Active1-Oct-07 9:06
mentorNot Active1-Oct-07 9:06 
AnswerRe: MSMQ Triggers Pin
led mike1-Oct-07 9:25
led mike1-Oct-07 9:25 
GeneralRe: MSMQ Triggers Pin
Not Active1-Oct-07 9:42
mentorNot Active1-Oct-07 9:42 
AnswerRe: MSMQ Triggers Pin
Pete O'Hanlon1-Oct-07 9:43
mvePete O'Hanlon1-Oct-07 9:43 
GeneralRe: MSMQ Triggers Pin
Not Active1-Oct-07 9:50
mentorNot Active1-Oct-07 9:50 
GeneralRe: MSMQ Triggers Pin
Pete O'Hanlon1-Oct-07 9:58
mvePete O'Hanlon1-Oct-07 9:58 
QuestionOverloading comparisson operator Pin
Fernando A. Gomez F.1-Oct-07 8:31
Fernando A. Gomez F.1-Oct-07 8:31 
AnswerRe: Overloading comparisson operator Pin
Not Active1-Oct-07 8:44
mentorNot Active1-Oct-07 8:44 
GeneralRe: Overloading comparisson operator Pin
Fernando A. Gomez F.1-Oct-07 8:50
Fernando A. Gomez F.1-Oct-07 8:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.