ComboBox in DataGridView

I have a form that has a DataGridView control (.NET 2.0) on it.  I am using 
a combobox in one of the columns and it works fine.  The only problem that I 
have is that the box with the arrow is displayed for all the rows all of the 
time for that column.  I would like to hide the box with the arrow until the 
cell gets the focus.  Is this possible?

I use the following code to build the DataGridView:

dgvTemplates.AutoGenerateColumns = false;

DataGridViewTextBoxColumn col1 = new DataGridViewTextBoxColumn();

col1.DataPropertyName = "Id";

dgvTemplates.Columns.Add(col1);

DataGridViewComboBoxColumn col2 = new DataGridViewComboBoxColumn();

col2.DataSource = dtGrade;

col2.DisplayMember = "Grade";

col2.ValueMember = "Grade";

col2.DataPropertyName = "Grade";

col2.HeaderText = "Grade";

dgvTemplates.Columns.Add(col2);


Thanks,

Tim 


0
tk
4/29/2010 2:33:10 PM
dotnet.languages.csharp 1931 articles. 0 followers. Follow

1 Replies
1231 Views

Similar Articles

[PageSpeed] 37

"tk" <tkelley@hrimaging.com> wrote in message 
news:OIdEnj65KHA.4648@TK2MSFTNGP06.phx.gbl...

>I have a form that has a DataGridView control (.NET 2.0) on it.  I am using 
>a combobox in one of the columns and it works fine.  The only problem that 
>I have is that the box with the arrow is displayed for all the rows all of 
>the time for that column.  I would like to hide the box with the arrow 
>until the cell gets the focus.  Is this possible?

Check out the DataGridViewComboBoxColumn.DisplayStyle property. 


0
Jeff
4/29/2010 3:59:24 PM
Reply:

Similar Artilces:

combobox
hi i am trying to create a combobox containing a list of names i want the list to default to a "dummy" value when the workbook is opened How do i do this? thanks kevin You would need a macro for that, assume that you use the combo box from the control toolbox, and that the linked cell is A2 in Sheet2 Private Sub Workbook_Open() Worksheets("Sheet2").Range("A2").Value = "Your_Dummy_Value" End Sub Right click the little excel icon to the left of the filemenu and select view code or press Alt + F11 and double click ThisWorkbook That's where the ma...

Requery combobox
I have a form that includes a combobox that has the following in its on enter event: Private Sub cbProjectPhase_Enter() Me.cbProjectPhase.Requery End Sub The query that is tied to this combox uses another field ("Cost Center") on this form as criteria to select records for this combobox. It works fine except when I go to the next record and click on that combobox it removes what is showing in the previous record's combobox's field because my selection "Cost Center" is different this time. I understand why this happens but I don't know how to get around it. I...

Populate combobox
Hello Why doesn't this populate my ActiveX combobox? Private Sub ComboBox1_Change() Dim row As Integer ' Make sure the RowSource property is empty Sheet1!ComboBox1.RowSource = "" Sheet1!ComboBox1.RowSource = "Sheet1!A1:A12" ' Add some items to the ActiveX combobox For row = 1 To 12 Sheet1!ComboBox1.AddItem Sheets("Sheet1").Cells(row, 1) Next row End Sub Change the exclamation point (!) to a period (.) after Sheet1 everywhere except in the row source reference that is within the quote marks. &quo...

Help With Simple Combobox Programming
I have a combo box on sheet1. When the user clicks on the combo box the first time ( it gets focus ) It should add/load all items from sheet2 column A. Now when the user selects from the combobox that item should be copied/placed on sheet1.A5 similarly the next item selected in the combo box should be placed below A6 and so on How can this be accomplished with code thx Hi, Use code like that : Private Sub cboIn_Click() Dim intR As Integer intR = Range("a4").CurrentRegion.Rows.Count Range("a4").Offset(intR, 0).Value = cboIn.Value End Sub Priv...

Help with ComboBox
Hi, I'm using Excel 2003 I have a spreadsheet using a ComboBox that allows selection of one of several sets of data. Each set is a 3 column row of data. I have the following properties set: BoundColumn: 2 TextColumn: 1 When a selection is made the ComboBox displays the column 1 value. The ComboBox seems to behave normally, except that when I close and open the file the combox initially displays the value of column 2 (instead of column 1). When a new selection is made it goes back to displaying the column 1 data. Shouldn't it always display the data as assigned by TextColu...

combobox into another combobox
i got 2 combo boxes in a worksheet. i want to link the 2 combo boxes together. combo2 will depend on which is selected to the combo1. eg: combo1 - accessories, card, ram list in combo2 will vary on the item selected from the combo1. let say: combo1 - accessories have been selected combo2 - slot fan, usb to ps2 convertor. can someone helps me!!! thxns in advance Hi Take a look at Debra Dalgleish's site for lots of information on Data Validation http://www.contextures.com/xlDataVal13.html and for the section using Combo boxes http://www.contextures.com/xlDataVal10.html -- Regards ...

Filling More than one field a combobox selection
I have a simple Address Form Suburb, State, PostCode Suburb is a combobox linked to a Post code table What I would like to do is for the user to look up Suburb by typing into the combo box and populate the state and postcode fields on selection. Am I going about this the right way? See www.allenbrowne.com. He has an excellent search function exactly like you need. -- Milton Purdy ACCESS State of Arkansas "Avid Fan" wrote: > I have a simple Address Form Suburb, State, PostCode > > Suburb is a combobox linked to a Post code table > &...

combobox in vista
hi , guys i meet the the same issue with below http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?&query=ComboBox+in+vista&lang=en&cr=&guid=&sloc=en-us&dg=microsoft.public.platformsdk.shell&p=1&tid=9d3eeb9e-54d2-457d-8fc0-2473b2e2b203 who can tell me how to solve this question, or must wait the next version of mfc welcome any idea. thanks in advance. Doesnt the workaround as mentioned in the thread work for you? -- Ajay "John" <John@discussions.microsoft.com> wrote in message news:D9722557-9FD2-4193-AE3C-AED94F3162CA@microso...

Cascading comboboxes in datasheet, is it possible?
I have 3 tables: 1) Table Projects with autonumber primary key ProjectID, ProjectName (text) 2) Table Activities with autonumber primary key ActivityID, ActivityName(text), ProjectID (foreign key) 3) Table HoursWorked with autonumber ID field, ProjectID, ActivityID and Hours (Number) Tables Activities and Projects are linked. One project can have many activities. In table HoursWorked users insert ProjectID, ActivityID and Hours. This third table is linked to a datasheet form. What I would like to do is to select projects and corresponding activities by using cascading combo boxes in th...

datagrid and combobox
Then how to associate a combobox to a datagrid ... Click on the type combobox and so taken with the data shows that this chosen in the combobox Not sure exactly what you're asking, but if it's what I think you can hook into the change notification on the combo box then send a message to your view to set the "grid" or whatever control you want to match the new selection in the combo box. I don't think you would associate them directly, but you could certainly cause a change in the combo box selection to change data in any other view or dialog in your program. To...

incorrect null value in combobox
Hello I have a combo with 2 columns. Everything is set up corectly (bound column, no of columns etc). Rowsource is a query which has 2 columns as well. All goes fine but from time to time, i don't know for what reason, I get the result me.combo.colum(0) or (1) = Null even though I should have not null values (the bound query returns not null values, I have checked) It is intriguing that this does not happen every time and also if I check the value of my combo with me.combo than it returns the correct result not null. Can I get the value of my second column other than...

Combobox
I have a custom control derived from ComboBox that I need to load itself depending on one of its parameter. What event can I use for that? It doesn't seem to have a "OnLoad" event... "Michel Racicot" <mracicot@hotmail.com> wrote in message news:B6C4B10E-FFB9-41E7-AFA9-15101714BE79@microsoft.com... >I have a custom control derived from ComboBox that I need to load itself >depending on one of its parameter. > > What event can I use for that? It doesn't seem to have a "OnLoad" > event... Technicality: There is no...

cascade combobox with one combobox in a subform
I have a form with a subform. The formfPerfEmissionGua) has a field called FuelClass. (Gas,Liquid,Duel,Multi) The subform(fPerfEmissionGuaDetails)is based off of a table called tFuel with the fields... FuelID -- GasLiquid -- FuelName 1 -- Gas -- Propane 2 -- Gas -- Buthane 3 -- Liquid -- JetA 4 -- Liquid -- Crude The subform is used as a dropdown choice of the above fields. It is a contiguous form. I would like to be able to choose the FuelClass - Gas in the main form, and the sub form drop down only show the fuels for Gas only (Pro...

combobox Question #2
I have a combobox which I am using to show upcoming meetings. What I would like to happen is if someone types in a date for this to show all the items on the page with that date. Is this possible The page is called "meetings" combobox rowsoure is from a2:e56536 Thanks Greg You could do an advanced filter on the data to another range, and link to that range. Recording a macro should get you the code. -- HTH RP (remove nothere from the email address if mailing direct) "Greg B" <laptopgb@ihug.com.au> wrote in message news:df9mg0$24s$1@lust.ihug.co.nz... >...

ComboBox
I am use to add a two dimensional array to a combobox to populate it, like this combobox.list=array(). In Excel I couldn't do that, the combobox only has the ListFillRange property. Is there a way of doing this without using the FillRange prop.? how about: Option Explicit Private Sub UserForm_Initialize() Dim i As Long Dim j As Long Dim myArray(1 To 3, 1 To 2) 'set your values For i = 1 To 3 For j = 1 To 2 myArray(i, j) = i & "--" & j Next j Next i With Me.ComboBox1 .ColumnCount = 2 .List = myArray End With End Sub JLon...

ComboBox question...
I have a ComboBox used on my spreadsheet that lets the end user select dates from a drop down menu. All the dates are out of site to the end user and listed in 3-Apr-05 format in the cellrange the ComboBox draws from. The problem is that after you make the date selection it changes the format to decimal (ie. 38445). Does anyone know why this is happening or how to make it display in date format? Also, I need to keep it in date format as other cells are using the date in a formula. Thanks, Ian ...

Conditional ComboBox
I have a combo box that allows users to choose a staffID, however if a certain item is selected in a previous combo box then my list of staffID's needs to be limited to a certain few. Currently this is what I have. If 27 < Service.Value < 40 Then Me.STAFFID.DropDown="24","159","176","321","326","337","383","124","390", "409" End If The certain item is the service. So if the service.value is between the range then the staffID's should be limited to only certain ID's otherwise...

Populating a combobox
Hi, Can someone post a sample code to populate a combobox. I want to populate a combobox with some strings that I get by querying an API. I do this: m_ComboControl.AddString(".............") in a loop. But when I run the program, the combobox doesnt get populated with the strings...Any idea? Thnx in adavnce! Joy2006 wrote: > Hi, > > Can someone post a sample code to populate a combobox. > > I want to populate a combobox with some strings that I get by querying > an API. > > I do this: > > m_ComboControl.AddString(".............") in ...

modificare valori combobox modulo personalizzato outlook 2007 con dati access.
Salve, ho creato un modulo personalizzato in outlook 2007. Ho la necessit� di inserirvi una combobox che vada a popolarsi con dei dati che ho in una tabella di Access 2007. Non riesco a farcela, qualcuno pu� aiutarmi?... Di seguito metto il mio codice, grazie. TG Option Explicit Public WS As Workspace Public DB As Database Dim z_z(0 To 100) As String Dim sSql As String Dim CurFolder Dim AllItems Dim NumItems Dim myOlApp As New Outlook.Application Dim myItem As Outlook.ContactItem Dim myPages As Outlook.Pages Dim combobox Private Sub Application_ItemLoad(ByVal Item As Object) Set WS...

AddString to Combobox
I've created a combobox with the toolbox manager. After I added a variable for that combobox I am doing something like this: m_ComboPartnerships.InitStorage(2,500); m_ComboPartnerships.AddString("asdf"); m_ComboPartnerships.AddString("xyz"); After this I didnt see any results, so I added: m_ComboPartnerships.SetCurSel(0); what allows me to see only "asdf". I was expecting it would behave like an internet dropdown, but I was wrong. How can I see all the element I've added?? Please help You must be getting the drop down and need to scroll down to s...

ComboBox
Hello, For some strange reason I cannot get the combobox componet to drop down the list when clicked. I've tried changing pretty much all the properties, including the type from DropDown to DropList. The version of Visual C++ I am running is Visual C++ .NET 2003. Can anyone help me? Thanks in advance. Sincerely, James Simpson Straightway Technologies http://straightway.no-ip.com Select the combo box in the resource editor. Now click on the arrow portion of the combo. This will give you the resizing handlers. Click on the middle handler at the bottom and increase the height o...

Number format for Combobox
Hi, I have a user form that reads a list of numbers and places them into a combobox. Often I have to add a new number to the list and here is the problem. If I type a new number into the list and run the form, the new number is not displayed in the combobox. I have found that if I drag the old number list down and increase the number to the new one I require and then delete any intervening numbers that are not required, the combo box will then read the new additional number. I have tried formatting all numbers to the same format but it makes no difference. It is no hardship for me t...

how to change the size of the scrollbar in a combobox
anyone has any ideas? I searched everywhere and could not get an answer. thanks dickson Scrollbar width is constant system-wide in Windows. It's adjustable under Control Panel, Display Settings. -- Jim Rech Excel MVP "Dickson Law" <dklaw1968@yahoo.com> wrote in message news:10c03178.0410070858.295429b7@posting.google.com... | anyone has any ideas? I searched everywhere and could not get an answer. | | thanks | | dickson hi, sorry, this cannot be done. >-----Original Message----- >anyone has any ideas? I searched everywhere and could not get an answer....

ComboBox
How do I create a column that has rows of combobox with two items in it -- Message posted from http://www.ExcelForum.com I am from the MS Excel support department at http://www.enterpriseprojectconsulting.com and we would be happy to assist you in resolving your issue Thank you Enterprise Project Consultin 2 Methods Someplace on the same worksheet where you want the 'combo box' to appear type in one comb box selection, or row, per cell - e.g. 'apples' in cell 'A1' and 'oranges' in cell 'A2'. Select the column that you want to the dropdown to appe...

Datagridview Combobox Values
Good Afternoon All, I have a datagridview dgv1 that has a combobox column in it. Each row should have an individual item to select from in the combobox. My code displays the same values in all of them. Any help would be great! Here's my code: Dim dsMP As DataSet = New DataSet() Dim intRow As Integer = 0 Dim intRows As Integer = dgvRO.Rows.Count Dim strPartNumber As String = "" Dim dt As DataTable = Nothing Dim dr As DataRow = Nothing For intRow = 0 To intRows - 1 strPartNumber = dgvRO.Rows...