Datagrid Problem

  • Thread starter Thread starter scorpion53061
  • Start date Start date
S

scorpion53061

In this code what do I have to do to get the read only and Height property
to work?
this is going into a datagrid.

Dim BOOKSLABEL As New ColoredTextBoxColumn
BOOKSLABEL.TextBox.BackColor = System.Drawing.SystemColors.Desktop
BOOKSLABEL.MappingName = "Label"
BOOKSLABEL.HeaderText = "Possible Fields"
BOOKSLABEL.Alignment = HorizontalAlignment.Left
BOOKSLABEL.TextBox.Height = 150
BOOKSLABEL.Width = 200
BOOKSLABEL.TextBox.ReadOnly = True
 
Hi,

To set the row height adjust the tablestyle preferredrowheight. To make a
column readonly set the datagridtextboxcolumn readonly property to true.

Ken
 
Hi Ken,

Can we set one column to read only? We can set the back colr and such in the
code below for one column...
 
Hi,

Yes.

Ken
------------------------
scorpion53061 said:
Hi Ken,

Can we set one column to read only? We can set the back colr and such in the
code below for one column...
 
HI ken,

In this scenario,
Dim BOOKSLABEL As New ColoredTextBoxColumn
BOOKSLABEL.TextBox.BackColor = System.Drawing.SystemColors.Desktop
BOOKSLABEL.MappingName = "Label"
BOOKSLABEL.HeaderText = "Possible Fields"
BOOKSLABEL.Alignment = HorizontalAlignment.Left
BOOKSLABEL.TextBox.Height = 150
BOOKSLABEL.Width = 200
BOOKSLABEL.TextBox.ReadOnly = True
how would you have made this column read only?
 
Hi,

Assuming the column in question is inherited from the DataGridTextBoxColumn,
you can just set it's
ReadOnly property to True.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
 
Hi,

Dim BOOKSLABEL As New ColoredTextBoxColumn
BOOKSLABEL.TextBox.BackColor = System.Drawing.SystemColors.Desktop
BOOKSLABEL.MappingName = "Label"
BOOKSLABEL.HeaderText = "Possible Fields"
BOOKSLABEL.Alignment = HorizontalAlignment.Left
BOOKSLABEL.TextBox.Height = 150
BOOKSLABEL.Width = 200
BOOKSLABEL.ReadOnly = True

Ken
 
I went wrong on the row...when teh user selected the row it would still
allow the user to delete it.
I dealt with that problem and the rest except one.

How if you make the grid cell size 40 for instance, make the text appear in
the middle of the cell aligned left?
 
Were you intending for this code to center it vertically in the cell or just
horizontally?

When I used it it always top justified just like mine...
 
Ken,

This code sample (I didnt get the vertical alignment working) but using an
Arraylist for the grid is very cool. Thank you for the sample.
 
Problem solved and thank you Ken. It now is vertically aligned with scroll
bars and word wrap.
 
Ken,

One more thought on this line.......

Do you know of a link or sample in the SDK that would let me depending on
the value of column 1 of the datagrid would put a combo box in the grid for
the second column? If hte value didnt equal what I was looking for then it
would not do this and leave it as a textbox?
 
This worked but........

Dim C As New ComboBox
C.Location =
DataGridSH.PointToClient(DataGridSH.MousePosition)
C.Items.Add("foobar")
C.Items.Add("hello world")
DataGridSH.Controls.Add(C)
C.BringToFront()

but if you came back to it it added it again and I couldnt get it to replace
the textbox currently in the grid.
 
Back
Top