473,473 Members | 2,215 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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
5 4589
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bill C. | last post by:
Hi, I'm trying to implement a ComboBox drop-down column for a DataGrid. When a cell is selected in the ComboBox column I overlay a ComboBox over the cell and call: this.comboBox.Show();...
2
by: john sutor | last post by:
Does anyone know how to create a combobox in a standard datagrid? I can create check boxes , but not the combobox
3
by: Kevin | last post by:
Hi Al I want to add two combobox columns in my datagrid. the one combobox column must be bound to the same datasource that the datagrid is, and the other combobox I just want to populate with a...
3
by: PeterZ | last post by:
G'day, After doing much searching and pinching bits of ideas from here there and everywhere I came up with a fairly 'clean' solution of including a comboBox into a dataGrid column. You can...
3
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article:...
2
by: Robert | last post by:
I'm sure this is a fairly basic question, but I've been looking all over the web for days for suggestions on how to do this. I've got a datagrid that's bound to a dataset on my form. It includes...
0
by: JL3574 l | last post by:
i have a datagrid with a combo box added in it's columns . the combobox pulls values from a database in it's dropdownlist fashion. my problem is that when i pick a select on the combo box it...
3
by: Doug | last post by:
Hi I have the following code (not mine) that populates a datagrid with some file names. But I want to replace the datagrid with a combo box. private void OnCurrentDataCellChanged(object sender,...
2
by: jaYPee | last post by:
i have search a lot of newsgroup and some website to find a sample for multi column combobox in datagrid but no luck. there are so many sample i found but it is not located in datagrid. i would...
1
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .....
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.