PC Review


Reply
Thread Tools Rate Thread

Can't set value of datagridview cell

 
 
=?Utf-8?B?ZGVubmlzdDY4NQ==?=
Guest
Posts: n/a
 
      16th Jul 2005
I'm going to bother you on one more question. Tell me if I'm out of line.
This one ha 441 views without an answer.

I might mention that these datagridviews are totally unbound. The column
headers I created in the column collection.

Can't set value of datagridview cell

The documentation claims you can set the cell value thusly:

Private Sub SetCellValue(ByVal myGrid As DataGrid)
Dim myCell As New DataGridCell()
' Use an arbitrary cell.
myCell.RowNumber = 1
myCell.ColumnNumber = 1
' Change the cell's value using the CurrentCell.
myGrid(myCell)= "New Value"
End Sub

MsgBox("new row index " & Me.DataGridView1.NewRowIndex.ToString)
MsgBox("rowcount " & Me.DataGridView1.RowCount.ToString())
gives me the respective messages 0 and 1 respectively. I might add that the
datagridview is unbound and without a datasource.

Dim aCell As New DataGridView1cell gives me the message
datagridview1cell is not defined.

Further in the documentation are examples. I adapted the examples

Dim rowArray As String()


'Dim row1() As String = {"Meatloaf", "Main Dish", "ground beef", "**"}
to
Dim row1 As String = {Me.WATopicID.ToString(), Me.KeywordSetTextBox.Text, "?"}

The questionmark is because the example is for all columns as textboxes.
Nowhere did I find documentation on how to fill a row with other controls as
columns, particularly a checkbox.

Dim rowArray As String()
For Each rowArray In rows
dataGridView1.Rows.Add(rowArray)
Next rowArray

However, rows is undeclared. It seems the documentation is behind the
current implementation of the beta framework.

Can somebody help me?

You might ask why I don't add a datasource for the keywords grid? Because I
have thousands of keywords. It's easier to just execute an insertquery to
the tableadapter and not have to drain a large amount of resources and slow
the user experience considerably.

dennist685

 
Reply With Quote
 
 
 
 
ÈÎÔ¶[΢Èí]
Guest
Posts: n/a
 
      18th Jul 2005
Hi Dennist,

Welcome for MSDN newsgroup!

For current issue, the DataGridViewCell class is a MustInherit class in
NET Framework beta v2.0, so we can not create a new instance for it
directly. The following document gives us more detail information about it:
http://msdn2.microsoft.com/library/h6eeb94b(en-us,vs.80).aspx

Based on my understanding, you want to add a checkbox control into the
current DataGridView, please notify me if I make a misunderstanding. I
suggest we use the below fragment code to add a column checkbox:
Dim column As DataGridViewColumn = New DataGridViewCheckBoxColumn()
column.DataPropertyName = "GoodGuy"
column.Name = "Good"
dataGridView1.Columns.Add(column)

I hope the suggestions were helpful. If you have any other concerns, please
feel free to let me know.. It's my pleasure to be of assistance.

Yuan Ren[MSFT]

 
Reply With Quote
 
=?Utf-8?B?ZGVubmlzdDY4NQ==?=
Guest
Posts: n/a
 
      19th Jul 2005
Yuan,

So far so good. However how to I associate the datagridviewcolumn with
datagridview1 in particular. I can see how I can create my three columns,
but I don't see how I can apply them to a particular datagridview.

I hope I'm explaining myself clearly. You were.

The second question is putting the values in row0. would they be
Dim row1 As String = {Me.WATopicID.ToString(),
Me.KeywordSetTextBox.Text,
checked}

Thanks for spending time solving my problems.

dennist685


""ÈÎÔ¶[΢ÈÃ*]"" wrote:

> Hi Dennist,
>
> Welcome for MSDN newsgroup!
>
> For current issue, the DataGridViewCell class is a MustInherit class in
> .NET Framework beta v2.0, so we can not create a new instance for it
> directly. The following document gives us more detail information about it:
> http://msdn2.microsoft.com/library/h6eeb94b(en-us,vs.80).aspx
>
> Based on my understanding, you want to add a checkbox control into the
> current DataGridView, please notify me if I make a misunderstanding. I
> suggest we use the below fragment code to add a column checkbox:
> Dim column As DataGridViewColumn = New DataGridViewCheckBoxColumn()
> column.DataPropertyName = "GoodGuy"
> column.Name = "Good"
> dataGridView1.Columns.Add(column)
>
> I hope the suggestions were helpful. If you have any other concerns, please
> feel free to let me know.. It's my pleasure to be of assistance.
>
> Yuan Ren[MSFT]
>
>

 
Reply With Quote
 
Kevin Yu [MSFT]
Guest
Posts: n/a
 
      20th Jul 2005
Hi Dennis,

To specify the column data that is displaying, you can use the
DataPropertyName property. Please check the following link for more
information.

http://msdn2.microsoft.com/library/584edt5s(en-us,vs.80).aspx

What do you mean by setting values in row0, if you need to set value for a
certain column, please use row0("columnname") = value

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
linking textbox to cell in a datagridview cell cj Microsoft VB .NET 12 7th Dec 2007 02:14 AM
Get the value of cell in a dataGridView jr1024 Microsoft C# .NET 1 10th Jul 2007 07:44 PM
Get Value of Cell on DataGridView Bails Microsoft VB .NET 3 13th Jun 2007 09:53 AM
Get the value of one cell from a DataGridView? Edwin Smith Microsoft C# .NET 3 21st Feb 2007 11:45 PM
Making DataGridView do row-by-row edit instead of cell-by-cell =?Utf-8?B?SGFzc2lhaA==?= Microsoft Dot NET Framework Forms 4 23rd Jun 2006 08:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:56 AM.