467,169 Members | 984 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,169 developers. It's quick & easy.

DataGrid ComboBox Column

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
  • viewed: 4389
Share:
5 Replies
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
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
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
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
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.

Similar topics

2 posts views Thread by Bill C. | last post: by
2 posts views Thread by john sutor | last post: by
3 posts views Thread by Kevin | last post: by
3 posts views Thread by TT (Tom Tempelaere) | last post: by
3 posts views Thread by Doug | last post: by
2 posts views Thread by jaYPee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.