HighTechTalks DotNet Forums  

Setting DataGridView Cell Properties

Dotnet Framework (WinForms DataBinding) microsoft.public.dotnet.framework.windowsforms.databinding


Discuss Setting DataGridView Cell Properties in the Dotnet Framework (WinForms DataBinding) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Jerry
 
Posts: n/a

Default Setting DataGridView Cell Properties - 05-01-2009 , 10:44 PM






I think this problem I'm experiencing is Data Binding related so I'm
reposting this message to include this group.

I'm having a problem with setting ReadOnly and ToolTipText properties for
DataGridView cells. I want to set these properties on the RowEnter event but
if I do this prior to any cell being entered I subsequently get an
InvalidArgument exception. I've found that if I set them after handling a
CellValidated event for the DGV everything works fine. I use a BindingSource
to a DataTable in my DataSet for the DGV. The DGV is on a TabControl. The
first RowEnter event occurs when I activate the tab containing the DGV. I can
set the properties during this event but once outside of my methods I get the
following error:

System.ArgumentException Message: InvalidArgument=Value of '3' is not valid
for 'rowIndex'. ParamName: NULL Data:
System.Collections.ListDictionaryInternal TargetSite:
System.Windows.Forms.DataGridViewElementStates GetState(Int32) HelpLink: NULL
Source: System.Windows.Forms StackTrace Information
********************************************* at
System.Windows.Forms.DataGridViewRow.GetState(Int3 2 rowIndex) at
System.Windows.Forms.DataGridViewRowCollection.Get NextRow(Int32 indexStart,
DataGridViewElementStates includeFilter) at
System.Windows.Forms.DataGridViewRowCollection.Get NextRow(Int32 indexStart,
DataGridViewElementStates includeFilter, DataGridViewElementStates
excludeFilter) at
System.Windows.Forms.DataGridView.CorrectRowFrozen State(DataGridViewRow
dataGridViewRow, DataGridViewElementStates rowState, Int32
anticipatedRowIndex) at
System.Windows.Forms.DataGridView.OnInsertingRow(I nt32 rowIndexInserted,
DataGridViewRow dataGridViewRow, DataGridViewElementStates rowState, Point&
newCurrentCell, Boolean firstInsertion, Int32 insertionCount, Boolean force)
at System.Windows.Forms.DataGridViewRowCollection.Ins ertDuplicateRow(Int32
indexDestination, DataGridViewRow rowTemplate, Boolean firstInsertion, Point&
newCurrentCell) at
System.Windows.Forms.DataGridViewRowCollection.Ins ertCopiesPrivate(DataGridViewRow
rowTemplate, DataGridViewElementStates rowTemplateState, Int32
indexDestination, Int32 count) at
System.Windows.Forms.DataGridViewRowCollection.Ins ertCopiesPrivate(Int32
indexSource, Int32 indexDestination, Int32 count) at
System.Windows.Forms.DataGridViewRowCollection.Add CopiesInternal(Int32
indexSource, Int32 count) at
System.Windows.Forms.DataGridView.RefreshRows(Bool ean scrollIntoView) at
System.Windows.Forms.DataGridView.OnBindingContext Changed(EventArgs e) at
System.Windows.Forms.Control.OnParentBindingContex tChanged(EventArgs e) at
System.Windows.Forms.Control.OnBindingContextChang ed(EventArgs e) at
System.Windows.Forms.Control.OnParentBindingContex tChanged(EventArgs e) at
System.Windows.Forms.Control.OnBindingContextChang ed(EventArgs e) at
System.Windows.Forms.Control.CreateControl() at
System.Windows.Forms.Control.SetVisibleCore(Boolea n value) at
System.Windows.Forms.TabControl.UpdateTabSelection (Boolean updateFocus) at
System.Windows.Forms.TabControl.OnSelectedIndexCha nged(EventArgs e) at
System.Windows.Forms.TabControl.WmSelChange() at
System.Windows.Forms.TabControl.WndProc(Message& m) at
System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m) at
System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr
wparam, IntPtr lparam)

This is for .NET 3.5. Any clues that you can provide that will help me
resolve this issue would be greatly appreciated?
--
Thanks,
Jerry


Reply With Quote
  #2  
Old   
Jerry
 
Posts: n/a

Default RE: Setting DataGridView Cell Properties - 05-03-2009 , 07:26 PM






Another point of interest that may be a factor is that I have some bound and
other virtual columns in the DGV. The properties that I'm setting are for the
virtual columns.
--
Thanks,
Jerry


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.