c#


Call CellFormatting when DataGridView is populated


I need to trim the cells in the DataGridView when it's populated with data.
I can't figure out how to call the CellFormatting event from within the DataBindingComplete Event. Surely it's as simple as;
private void iCBOMHDataGridView_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
iCBOMHDataGridView_CellFormatting();
}
I am doing something similar that might help. In my case, I am setting an inactive user's whole row to gray text, but it is still cell formatting:
dgvUsers.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.dgvUsers_CellFormatting);
this.Controls.Add(dgvUsers);
The lines above happen before you dgvUsers.Enabled = true; The grid has been loaded, but not displayed. Then the handler that gets called is:
private void dgvUsers_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
DataRowView row = dgvUsers.Rows[e.RowIndex].DataBoundItem as DataRowView;
if (row != null && row.Row.ItemArray[7].Equals("N"))
{
e.CellStyle.ForeColor = Color.Gray;
dgvUsers.Invalidate();
}
}
The main difference between the cell styling I do and yours is that I am not working with the actual values in the cells, just their styling.

Related Links

Get Duplicates in List and Edit Item
Should I await a 'async Task' function if I don't care its return value? [duplicate]
Autofac open generics: factory IIndex based on <U>
string with StingBuilder error c#
Mono SQLite with CF 3.5
EWS Oauth Exception: The request failed. The remote server returned an error: (401) Unauthorized
Reports in MS Word. Any library? [closed]
Display two model in a View?
How to Install Visual Studio Extension into specific folder?
Accessing a variable from player prefs in another scene
ExtendedSplash page DismissedEventHandler not invoked on Windows 10 IoT Core
ASP.NET MVC 5 How can I catch specifically all System.NullReferenceExceptions and redirect to a view, so my program doesnt crash?
Custom file parser slows down with every next file
C# visual studio publish shortcut file (.lnk) to user desktop
Make cell clickable in asp gridview
Issue of propertyChanged update for all subproperty in a class in winform

Categories

HOME
asterisk
ssms
optimization
kendo-ui
redux
macros
qemu
where
ms-application-insights
clip-path
wavefront
vsixmanifest
ephesoft
software-collections
openbsd
dynamics-crm-2011
osrm
mongodb-replica-set
react-select
google-closure-compiler
luis
multibinding
brightway
amazon-data-pipeline
audio-streaming
passbook
bug-reporting
include-path
beaker-notebook
connection-pooling
suitescript
inspec
akavache
visual-studio-community
dynamics-ax-2012-r3
pushpad
ipython-parallel
openoffice-impress
exacttarget
urhosharp
directions
circle
flickr
dom4j
azure-vm-scale-set
maven-2
word-wrap
motion
gem-fury
lfe
cowboy
ssdp
intervention
html-entities
django-cors-headers
android-doze-and-standby
htop
richtext
r-commander
hellosign
cardview
recursive-query
blackberry-webworks
disconnect
rowname
cosign-api
queuing
supervised-learning
avaudiorecorder
nugetgallery
periodic-processing
custom-build-step
ooad
ewam
dynamics-nav-2013
android-facebook
producer-consumer
windows-kernel
eggplant
pdcurses
firewire
autopep8
bungeecord
pymol
data-quality-services
growl
amzi-prolog
git-subtree
pthreads-win32
node-mongodb-native
mdp
node-amqp
grape-api
ojb
nsnumber
select2-rails
exi
custom-cursor
php-gettext
datasheet
pinchzoom
automapper-2
isgl3d
xpolog
youtube.net-api
mass-emails
xslt-grouping
system-analysis
mysql-logic
scala-designer
opengl-to-opengles
projectgen
office-2003
memory-consumption

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App