c#


DoubleClick on DataGridView to get more informations


Does anybody know how to make, when you double click on a cell in DataGridView a messagebox appears with more information. So for example i want my DataGridView to only display name and surname but when you Double Click it a messagebox appears with more information like age, heght...
Thanks for your help!
First you are going to need to subscribe to the 'CellDoubleClick' event like so:
yourDataGridView.CellDoubleClick += yourDataGridView_CellDoubleClick();
This will cause you program to start listening for the double click. In the same class, you have to define the behavior that you want when the DataGridView is double clicked. The DataGridViewCellEventArgs parameter has values for the current row (e.RowIndex) and the current column (e.ColumnIndex). Here is an example using one of my DataGridViews:
private void dgvContacts_CellDoubleClick(object sender, DataGridViewCellEventArgs e) {
//Make sure that the user double clicked a cell in the main body of the grid.
if (e.RowIndex >= 0) {
//Get the current row item.
Contact currentContact = (Contact)dgvContacts.Rows[e.RowIndex].DataBoundItem;
//Do whatever you want with the data in that row.
string name = currentContact.Name;
string phoneNum = currentContact.Phone;
string email = currentContact.Email;
MessageBox.Show("Name: " + name + Environment.NewLine +
"Phone number: " + phoneNum + Environment.NewLine +
"Email: " + email);
}//if
}//dgvContacts_CellDoubleClick

Related Links

Good parsing approach after tokenization [closed]
Logging in Microsoft Azure TableController
Couldn't zip blank text file (size 0KB) in UWP (Windows 10 App) C#
Print Document pdf c#
System.Drawing.FontFamily does not accept Uri-based Font
Adding search function to an invoice application
How Do I Set Z-Index in an ItemsControl with a Data Binding?
How to accept values as doubles in a textbox in ASPX C# Website?
Searching for Singular and Plural of a word in Search Engine
Unable to re-assign JavaScript variables with new Razor data?
Handle inconsistent date format string conversion to DateTime
Display Graph with Vertices and Edges in UWP
MvvmLight Messaging - What is the proper way to register and unregister a message?
Validation error message displays the entire text of the property in Asp.Net MVC 5
Add ListView item to a simple list?
Google Datastore authentication issue - C#

Categories

HOME
postgresql
azure-active-directory
ftp
system-calls
process
popover
reference
nagios
singleton
datetimepicker
symfony-sonata
obd-ii
angularjs-ng-repeat
rename
theory
fastreport
k-means
conditional-formatting
jq
combinations
opengraph
wai-aria
scrapy-spider
windows-mobile
tftp
jms-topic
ds-5
jboss-arquillian
wordpress-rest-api
choco
epub
flickr
webspeech-api
n1ql
dom4j
cocoa-scripting
flex3
blueimp
julia-jump
pexpect
libzip
g77
import.io
noise
serialversionuid
px4
playframework-1.x
was
group
lattice
dimensionality-reduction
settext
networkstream
require-handlebars
netlink
instaparse
hoare-logic
avi
usps
salesforce-service-cloud
clear
cascading
windows-phone-8-emulator
cyberduck
tess4j
consul-template
avrcp
pdcurses
clearquest
targetprocess
avd
gcc-warning
radgrid
service-broker
data-quality-services
mri
novell
html5-filesystem
android-library
expresso-store
big-endian
animationdrawable
parsec
motorola-droid
advanceddatagrid
openwrap
file-processing
nbehave
lgpl
large-data-volumes
numerical-computing
dgml
j++
office-2003
ironpython-studio

Resources

Encrypt Message