c#


datagridview all cell values pass to label


private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0 || e.ColumnIndex < 0)
return;
string id, name, price, desc, quan;
id = dgvWarp.Rows[e.RowIndex].Cells[0].Value + "";
name = dgvWarp.Rows[e.RowIndex].Cells[1].Value + "";
price = dgvWarp.Rows[e.RowIndex].Cells[2].Value + "";
desc = dgvWarp.Rows[e.RowIndex].Cells[3].Value + "";
// quan = dgvWarp.Rows[e.RowIndex].Cells[4].Value + "";
label2.Text = id;
label3.Text = name;
label4.Text = price;
label5.Text = desc;
}
Here is my cell click event handler code.But this code not fired which i need.Actually i want datagridview cell values pass to label automatically.if i entered values in some cells only pass data to label remains blank,if i enterd all cells show all labels as per images
only 1st rows shows the values,if i entered 1st column 2nd row cell (test2)then it will shows
test2 in place of test1.
this is my problem
Give the lable name according to Row and Column index. ie. lblRow0Col0, lblRow0Col1, lblRow1Col2 etc.
then write the following code in CellValidating Event
private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
String lblName = String.Format("lblRow{0}Col{1}", e.RowIndex, e.ColumnIndex);
Label lbl = (TextBox)this.Controls[lblName];
lbl.Text = e.FormattedValue.ToString();
}

Related Links

List of elements doesnt follow my recursion method c#
Cannot deserialize string from BsonType ObjectId in MongoDb C#
Inserting a preexisting AutoCAD drawing into a current drawing
Save As Dialog box in asp.net
nHibernate Many-to-Many and Cascade Delete
Using AngularJS to post form data to a ViewModel that is defined within ASP.NET MVC application
How to have a ListBox child item event not call parent event?
SelectList without using hardcode names
wpf conflict between listview and combobox
How do I return json for 404s and 403s in WebAPI?
C# Script Error "Use of Unassigned variable 'line'? [duplicate]
How to place gameobject to mouse position
System.EngineExecutionException in unsuspected place
EditText inputType & Number Format in Arabic Culture
How to get Text from UI.InputField?
How to parse a time (hours, minutes) -from a string by using regex?

Categories

HOME
qlikview
airflow
autohotkey
ftp
intellij-idea
sql-server-2014
postgresql-9.3
conceptual
boxplot
okhttp3
arguments
snmp
terminal
multipartform-data
symfony-3.2
meson-build
install
browserstack
android-webview
phpexcel
rename
adroitlogic
oxid
luis
brightway
google-calendar-api3
loader
draw2d
glibc
datazen-server
gnu-screen
connection-pooling
deployment-descriptor
scripting-language
boosting
git-submodules
key-bindings
ibm-bpm
language-detection
loopback
qt-designer
visual-prolog
imageprocessor
apache-falcon
android-geofence
border-layout
const
lfe
icu
android-graphview
bzip2
flume-ng
paperclip
intervention
inner-join
serverless-architecture
runner
ionic2-select
dynamic-linking
openpgp.js
timefield
networkstream
boost-bind
phpdesigner
radar-chart
stdlist
code-translation
opendolphin
webservices-client
random-sample
identifying
dnvm
joomla3.3
eula
gcc-warning
parseexception
autopep8
xmla
fiware-health
kss
clearcanvas
javacompiler
azure-worker-roles
serializer
angular-file-upload
nspopupbutton
sigma-grid-control
slimscroll
infor-eam
node-mongodb-native
windows-phone-store
nomachine
ekevent
code-complete
mencoder
myrrix
kendo-window
nsnumber
setcookie
android-memory
optimistic-concurrency
facebook-winjs-sdk
scsf
capitalization
cherokee
log-shipping
windows-xp-embedded
symfony-1.2
lwp
excellibrary
nyromodal
nscharacterset
jquery-attributes
pitch-shifting
bootstrap-protocol
tracd

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile