Link to home
Start Free TrialLog in
Avatar of jeff Lee
jeff Lee

asked on

Add and bind combobox inside datagridview c#

Hi,
    I add and bind combobox inside datagridview c# and set datagridview.Readonly = true in default.
The following is what I want.
 If the readonly of property in datagridview is true, the combobox inside datagridview can display the values as some control like textbox.
User generated image
When I want to insert or edit records, I  set readonly = false, the datagridview can show as follows.
User generated imageDoes it possible?

Thanks.

jeff



 

Avatar of Dorababu M
Dorababu M
Flag of India image

Can you share the code? when I tried the same I didn't see the behavior as you said I see the combo box as desired even the both of the properties are set to read only
Avatar of jeff Lee
jeff Lee

ASKER

Hi Dorababu M,
   I just change the ReadOnly property of a DataGridView and never set ReadOnly property of combobox inside datagridview. When users insert and edit records, the system will change the ReadOnly property of a DataGridView to false.
   Thanks.

jeff
Hi,
   Briefly, when users insert and edit records, the datagridview can display record with combobox. But if users just select data, I just hope the datagridview can display record with textbox in the same column. That's what I want. The issue is very easy in Delphi. I just ask if it is possible in visual studio.
   Thanks.

jeff
 
Still not clear but If I understood correctly in the same column you are trying to display text box and combo box column based on edit/update. Initially it will display a textbox on clicking edit it will display combo box?
Hi Dorababu M,
>>>>>> Initially it will display a textbox on clicking edit it will display combo box?
 That's correct.

jeff
How are you doing the edit of a row any button or on row click?
Hi Dorababu M,
The form just like as follows.
User generated image
When users want to insert and edit records, firstly they should press Edit.
Thanks.

jeff
 
OK how are you adding the columns to grid is it from any database or you are adding the columns manually? Only one row you will select and click on edit?
ASKER CERTIFIED SOLUTION
Avatar of Dorababu M
Dorababu M
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Dorababu M,
   It can work, but it need more code in visual studio. I must be familiar with the visual studio. I'm just curious  why it can't simplify the code in visual studio.

   Thanks.

jeff
What you mean by more code? Does that work for you?
Hi Dorababu M,
 Ya, it work fine for me. but I can solve the problem using simple code in Delphi. That's what I mean.
 Life is really simple, but we insist on making it complicated.

I really appreciate for your help.

jeff
Hi Dorababu M,

    I found another solution very easy and simple.

User generated image
  It's really amazing.

jeff