By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,587 Members | 1,079 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,587 IT Pros & Developers. It's quick & easy.

DataGrid ComboBox Column

P: n/a
I have a combobox column in a datagrid. (I am using the example from Geoge Shepard's website on deriving a custom column style from DataGridTextBoxColumn). The problem I am having is when you make a selection in the combobox, for a new record, the selected value does not appear until you tab out of that column. This only happens on a new record. If I change the value on an existing record, the combo box reflects my selection.

Thanks,
Lynn C.
Nov 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi Lynn,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that in a new record, the selected value
does not appear until you tab out of that column. If there is any
misunderstanding, please feel free to let me know.

Could you let me know how the selected value doesn't appear? It remains to
be null or you could not get the selected value in code? Based on my
research, the demo provided on that web site works fine when adding a new
row. Please try to download it from the following URL and see if it works:

http://www.syncfusion.com/faq/winfor...BoundCombo.zip

For a VB.NET version:
http://www.syncfusion.com/faq/winfor...ndCombo_vb.zip

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #2

P: n/a
Hi Lynn,

I have made some changes to the sample application provided by the website
and have changed the combobox column to the first column. However, I cannot
repro this issue when adding a new row in the DataGrid. Can you try it with
the sample application?

If the problem still persists, could you send me a repro package? Remove
'online' from the no spam alias is my real email address.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #3

P: n/a
Hi Lynn,

I mean if you can make a small repro package, you can send it by email
directly to me. Remove 'online' from that anti-spam mail address is my real
mail address.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #4

P: n/a
Hi Lynn,

I have re-checked it and yes, I was able to repro it. After debugging, I
found executing the following statement in Edit method makes the ComboBox
displays the first item.

this.ColumnComboBox.Visible = true;

Now, I have re-ordered the statement and put that statement before
assigning ColumnComboBox.SelectedIndex. Use the following as
DataGridComboBoxColumn.Edit method is a workaround to this issue.

protected override void Edit(System.Windows.Forms.CurrencyManager source,
int rowNum, System.Drawing.Rectangle bounds, bool readOnly, string
instantText, bool cellIsVisible)
{
base.Edit(source,rowNum, bounds, readOnly, instantText , cellIsVisible);

_rowNum = rowNum;
_source = source;

this.ColumnComboBox.Visible = true;
ColumnComboBox.Parent = this.TextBox.Parent;
ColumnComboBox.Location = this.TextBox.Location;
ColumnComboBox.Size = new Size(this.TextBox.Size.Width,
ColumnComboBox.Size.Height);
ColumnComboBox.SelectedIndex =
ColumnComboBox.FindStringExact(this.TextBox.Text);
ColumnComboBox.Text = this.TextBox.Text;
this.TextBox.Visible = false;
this.DataGridTableStyle.DataGrid.Scroll += new EventHandler(HandleScroll);

ColumnComboBox.BringToFront();
ColumnComboBox.Focus();
}
HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #5

P: n/a
Thanks Kevin. That fix the problem.

"Kevin Yu [MSFT]" wrote:
Hi Lynn,

I have re-checked it and yes, I was able to repro it. After debugging, I
found executing the following statement in Edit method makes the ComboBox
displays the first item.

this.ColumnComboBox.Visible = true;

Now, I have re-ordered the statement and put that statement before
assigning ColumnComboBox.SelectedIndex. Use the following as
DataGridComboBoxColumn.Edit method is a workaround to this issue.

protected override void Edit(System.Windows.Forms.CurrencyManager source,
int rowNum, System.Drawing.Rectangle bounds, bool readOnly, string
instantText, bool cellIsVisible)
{
base.Edit(source,rowNum, bounds, readOnly, instantText , cellIsVisible);

_rowNum = rowNum;
_source = source;

this.ColumnComboBox.Visible = true;
ColumnComboBox.Parent = this.TextBox.Parent;
ColumnComboBox.Location = this.TextBox.Location;
ColumnComboBox.Size = new Size(this.TextBox.Size.Width,
ColumnComboBox.Size.Height);
ColumnComboBox.SelectedIndex =
ColumnComboBox.FindStringExact(this.TextBox.Text);
ColumnComboBox.Text = this.TextBox.Text;
this.TextBox.Visible = false;
this.DataGridTableStyle.DataGrid.Scroll += new EventHandler(HandleScroll);

ColumnComboBox.BringToFront();
ColumnComboBox.Focus();
}
HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.