I have used this following:
private void EditingControlS howing(object sender, DataGridViewEdi tingControlShow ingEventArgs e)
{
DataGridViewCom boBoxEditingCon trol cbo = e.Control as DataGridViewCom boBoxEditingCon trol;
cbo.DropDownSty le = ComboBoxStyle.D ropDown;
}
private void dataGridView1_C ellValidating(o bject sender, DataGridViewCel lValidatingEven tArgs e)
{
if (e.ColumnIndex == this.dataGridVi ew1.Columns[0].Index)
{
DataGridViewCom boBoxColumn comboBoxColumn = (DataGridViewCo mboBoxColumn)th is.dataGridView 1.Columns[0];
object eFV = e.FormattedValu e;
if (!comboBoxColum n.Items.Contain s(eFV))
{
comboBoxColumn. Items.Add(eFV);
this.dataGridVi ew1.CurrentCell .Value = e.FormattedValu e;
}
}
}
}
make datagridviewcom boboxcolumn working for type new text which is not in the drop down list.
However, after that, if i want to type a text in the list, it ignore it. It just accept opening the arrow and selecting a item with a mouse or up down key. And my user want it badly, they prefer to type everything, no matter whether it is or not in the drop down list. Any help?
Thanks
Helen
3 3162
Private Sub DataGridView1_E ditingControlSh owing(ByVal sender As System.Object, ByVal e As System.Windows. Forms.DataGridV iewEditingContr olShowingEventA rgs) Handles DataGridView1.E ditingControlSh owing
Try
If COLUMNINDEX= 2 Then
cbo = CType(e.Control , DataGridViewCom boBoxEditingCon trol)
AddHandler cbo.SelectedInd exChanged, AddressOf cbo_selectchang ed
End If
Dim comboBoxColumn As DataGridViewCom boBoxColumn = _
DataGridView1.C olumns(2)
If (DataGridView1. CurrentCellAddr ess.X = _
comboBoxColumn. DisplayIndex) Then
Dim cb As ComboBox = e.Control
Dim s As String
If (cb IsNot Nothing) Then
cb.DropDownStyl e = ComboBoxStyle.D ropDown
End If
End If
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try
End Sub
Private Sub cbo_selectchang ed(ByVal sender As Object, ByVal e As EventArgs)
Try
If columnindex= 2 Then
ada = New OleDbDataAdapte r("select DISTINCT prodcode from Table1 where prodname='" + cbo.SelectedIte m.ToString() + "' ", con)
Dim dt As New DataTable
ada.Fill(dt)
If dt.Rows.Count > 0 Then
DataGridView1.I tem(1, i).Value = dt.Rows(0).Item Array(0).ToStri ng()
End If
End If
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try
End Sub
Private Sub DataGridView1_C ellValidating(B yVal sender As System.Object, ByVal e As System.Windows. Forms.DataGridV iewCellValidati ngEventArgs) Handles DataGridView1.C ellValidating
Dim comboBoxColumn As DataGridViewCom boBoxColumn = _
DataGridView1.C olumns(2)
If (e.ColumnIndex = comboBoxColumn. DisplayIndex) Then
If (Not comboBoxColumn. Items.Contains( _
e.FormattedValu e)) Then
comboBoxColumn. Items.Add(e.For mattedValue)
DataGridView1.I tem(2, e.RowIndex).Val ue = e.FormattedValu e
End If
End If
End Sub
try this...
thanks
vidhya
Thanks for the help! It really helps!!
Now I found a problem with it, it works with keyboard very well now. But when one user happened to use mouse click to select a a value, then it pop up an error exception"NullR eferenceExcepti on" which i can not catch it. Do you know what cause that? Thanks again!
Helen
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: David |
last post by:
How can I (in PHP) have my first edit box focused and ready for keyboard
input when the page loads
(yes, I am new to php :-D )
|
by: Andreas Horneff |
last post by:
Hi at all,
I've got a problem. I've a program written in Borland C++ Builder which is
running
on a small PC with a Touch-Screen.
At the program are several Edit-Boxes. Is there a posibility, that a
Keyboard will pop up
at the screen, whenn I click on the Edit-Box? I've no idear, how I can solve
my problem.
|
by: MLH |
last post by:
After running the following code snippet...
MyURL = "http://tycho.usno.navy.mil/what.html"
msXML.Open "GET", MyURL, False
msXML.send
I would like to execute code to perform essentially
what would amount to clicking Edit, Select All, CTRL-C
in Internet Explorer to capture some basic time 'n date
text from the military site and parse it.
|
by: Michelle Stone |
last post by:
Hi
I am doing a bilingual .NET application for
English/Arabic. On a web form, I have some edit boxes for
data entry in Arabic and some for entry in English. Right
now the user has to change his keyboard language by
pressing ALT+SHIFT (or by changing the language manually
elsewhere) each time he wants to shift from one language
to another.
|
by: Woody Splawn |
last post by:
We have a client server application where we would like to not show Save and
Cancel buttons on a winform until the user has actually entered something
into a textbox or combobox etc., and there is something to actually save.
This logic is fundamental to the way we would like to do things in general
so it is worth our while to get this figured out correctly once and for all.
To my mind, what needs to be done is to be able to detect when...
| |
by: Vish |
last post by:
Hi,
I amplanning on having a rea-only and edit states for my form. But it do not
want my form and its controls to look different or disabled. I am planning on
having a edit button that brings the form from read-only to a edit state. Is
there any easy or built-in way of doing this in .NET?
My preimary purpose for doing it because the combobox controls on my form
take a while to load all their data from the database. Since the user uses...
|
by: Mick_fae_Glesga |
last post by:
Hello everyone!
OK, I'm writing a windows program that requires the user to enter
Cyrillic characters into an Edit control.
But, I can't seem to get the Cyrillic characters to appear in the Edit
Control... I get underscores '_'
I know the cyrillic keyboard works... I use it in word programs, and
other apps...
|
by: bemanian |
last post by:
Hi,
This is a simple DataGridView in a windows form which contains a number
of other controls as buttons, text boxes and so on. The problem is when
the data grid cell editing is conducted via the entries by the
keyboard, combined by entries via the other control buttons (within the
win-form). It seems pressing any other control within the form suspends
the cell editing, expectedly. Then the insertion of the characters into
the cell via...
|
by: tim8w via DotNetMonster.com |
last post by:
I am using a DataGridViewComboBox in a DataGridView. When a user selects a
radio button, I would like to clear all the items in the DataGridViewComboBox
and repopulate with new values. I do this as follows:
Dim iIndex As Integer
Dim dgcb As DataGridViewComboBoxCell
For iIndex = 0 To dgvRecipe.RowCount - 1
dgcb = dgvRecipe.Rows(iIndex).Cells("Measure")
|
by: DominicHelen |
last post by:
I have a datagridviewcomboboxcolumn with that I can type a new value which is not in the drop down list. But I can not type a value which is in the list with keyboard. I can only scroll down to select it. Since my user need to fill a cell value really quick, they don't want to use a mouse or up, down key to select a value. I tried a normal ComboBox, it can do work this well. I wonder why datagridviewcomboboxcolumn couldn't do it.
Any help...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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 we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |