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



 

C#

Avatar of undefined
Last Comment
jeff Lee
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
Avatar of jeff Lee
jeff Lee

ASKER

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
 
Avatar of Dorababu M
Dorababu M
Flag of India image

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?
Avatar of jeff Lee
jeff Lee

ASKER

Hi Dorababu M,
>>>>>> Initially it will display a textbox on clicking edit it will display combo box?
 That's correct.

jeff
Avatar of Dorababu M
Dorababu M
Flag of India image

How are you doing the edit of a row any button or on row click?
Avatar of jeff Lee
jeff Lee

ASKER

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
 
Avatar of Dorababu M
Dorababu M
Flag of India image

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of jeff Lee
jeff Lee

ASKER

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
Avatar of Dorababu M
Dorababu M
Flag of India image

What you mean by more code? Does that work for you?
Avatar of jeff Lee
jeff Lee

ASKER

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
Avatar of jeff Lee
jeff Lee

ASKER

Hi Dorababu M,

    I found another solution very easy and simple.

User generated image
  It's really amazing.

jeff
C#
C#

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).

98K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo