|
-
Apr 3rd, 2007, 08:56 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] [2005] Only enable 1 column in dataGridview?
Is there a simple way to only enable the 1st column in a datagrid. I want the user to simply select a range or single items from column 1 which are then added to a listbox.
The problem is if they start selecting from the other columns. I put different events in like on Cell Click etc... to jump to the 1st column but there's too much that can go wrong. Would be simpler to just only enable 1 column.
-
Apr 3rd, 2007, 09:07 AM
#2
Fanatic Member
Re: [2005] Only enable 1 column in dataGridview?
Code:
For i As Int32 = 1 To grid.Columns.Count - 1
grid.Columns(i).ReadOnly = True
Next
or
Code:
For i As Int32 = 1 To grid.Columns.Count - 1
grid.Columns(i).Visible= True
Next
If your problem is solved, please use the Mark Thread As Resolved under Thread Tools!
Show Appreciation. Rate Posts!
-
Apr 3rd, 2007, 09:32 AM
#3
Thread Starter
Frenzied Member
Re: [2005] Only enable 1 column in dataGridview?
I need all columns to be displayed, but only the cells in column 1 to actually be selectable.
-
Apr 3rd, 2007, 09:34 AM
#4
Re: [2005] Only enable 1 column in dataGridview?
Just set SelectionMode to FullRowSelect, then get the value from the first column in all the selected rows.
-
Apr 3rd, 2007, 09:56 AM
#5
Thread Starter
Frenzied Member
Re: [2005] Only enable 1 column in dataGridview?
Cheers JMC,
I did it using this for anyone else learning it who might find it useful in the future:
vb Code:
For Each itm As DataGridViewRow In Me.DataGridView1.SelectedRows
Me.ListBox1.Items.Add(Me.DataGridView1.Item(0, itm.Index).Value.ToString)
Next
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|