|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
OK, I have 20 columns in a datagrid, but I only want to show about 10 of them...
I am using this code which dumps all 20 columns into my app: Code:
SqlDataAdapter1.Fill(DataSet11) dgQuestions.DataSource = DataSet11.Tables(0) I looked on a few sites and they say that this should work to "hide" a column: Code:
dgQuestions.Columns(1).ColumnMapping = MappingType.Hidden Of course this is supposted to hide column #1. I am working in Visual Studio.Net and when I try this code, I get a blue underline and the error says: "Columns" is not a member of System.Windows.Forms.DataGrid Anyone ideas would be nifty. |
|
#2
|
||||
|
||||
|
Example:
Code:
Try
Conn = New SqlConnection("Your ConnectionString")
da = New SqlDataAdapter("SELECT DepartmentID, DepartmentName FROM Department", Conn)
ds = New DataSet
da.Fill(ds, "Dept")
Next line hides column.
ds.Tables(0).Columns("DepartmentID").ColumnMapping = MappingType.Hidden
DataGrid1.SetDataBinding(ds, "Dept")
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
Conn.Close()
End Try
|
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > "hiding" columns in Datagrid |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|