dsmithcorteksys
New member
- Joined
- Jun 4, 2007
- Messages
- 2
- Programming Experience
- 1-3
Thanks in advance if anyone has any advice for the issue I am trying to resolve here. I currently have a datagrid view populated in a form within my application and previously I had all columns and cells displaying as text fields. Now I have 4 new columns (6-9 in the code below) that I want to display as simple combo menus (not bound to a table). 
This code will run but it doesn’t turn the columns I want into combo selections; it inserts new columns into my grid. The number of new columns that are output to the grid in this situation more than doubles the number of columns existing in the dataset that I am populating the grid with. Also the new columns that are inserted do have the combo menus that I created, but the grid is still not correct. I am not sure that dgModules.Columns.Insert(column index, cboHBSize)
is the correct solution to changing the last 4 columns to display combobox menus?
I am using:
Visual Studio 2005, Visual Basic.NET
In this scenario I am calling a single function in my form class that I am using to format the columns of the grid I am working with. Here is that block of code:
	
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Here is the grid population process I am using (I am using XML because there is also another class object instantiated in the middle of this operation that I using to convert dimensions of certain columns). 
- select from database
- read into a data table
- declare new dataset and place the
the data table in the dataset
- use the dataset to write an XML
file (conversion process takes place for some values in the dataset)
- declare a new dataset and read XML
file into the dataset (conversion process takes place for some values in the dataset)
- declare a new dataview and populate the
dataview with the current dataset
- assign the current dataview to the datagrid's
data source
- format the columns of the grid
	
		
			
		
		
	
				
			This code will run but it doesn’t turn the columns I want into combo selections; it inserts new columns into my grid. The number of new columns that are output to the grid in this situation more than doubles the number of columns existing in the dataset that I am populating the grid with. Also the new columns that are inserted do have the combo menus that I created, but the grid is still not correct. I am not sure that dgModules.Columns.Insert(column index, cboHBSize)
is the correct solution to changing the last 4 columns to display combobox menus?
I am using:
Visual Studio 2005, Visual Basic.NET
In this scenario I am calling a single function in my form class that I am using to format the columns of the grid I am working with. Here is that block of code:
			
				VB.NET:
			
		
		
		Public Sub GetGridColumnAppearance() 
        ' Make the ModuleID column invisible 
        With dgModules.Columns(0) 
            .Visible = False 
        End With 
        ' Make the Module Identity Column 
        ' read only so these values cannot be modified 
        With dgModules.Columns(1) 
            .ReadOnly = True 
            .HeaderText = "Module Id" 
            .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells 
            .SortMode = DataGridViewColumnSortMode.NotSortable 
        End With 
        With dgModules.Columns(2) 
            .HeaderText = "Top Elevation" 
            .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells 
            .SortMode = DataGridViewColumnSortMode.NotSortable 
        End With 
        With dgModules.Columns(3) 
            .HeaderText = "Length" 
            .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells 
            .SortMode = DataGridViewColumnSortMode.NotSortable 
        End With 
        With dgModules.Columns(4) 
            .HeaderText = "Width" 
            .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells 
            .SortMode = DataGridViewColumnSortMode.NotSortable 
        End With 
        With dgModules.Columns(5) 
            .HeaderText = "Horizontal Rebar Centers" 
            .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells 
            .SortMode = DataGridViewColumnSortMode.NotSortable 
        End With 
        ' combo box drop down menus for each of the following 
        ' columns 
        With dgModules.Columns(6) 
            .HeaderText = "Horizontal Bar Size" 
            .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells 
            .SortMode = DataGridViewColumnSortMode.NotSortable 
            Dim cboHBSize As New DataGridViewComboBoxColumn 
            cboHBSize.Items.Add("#4") 
            cboHBSize.Items.Add("#5") 
            cboHBSize.Items.Add("#6") 
            dgModules.Columns.Insert(6, cboHBSize) 
        End With 
        With dgModules.Columns(7) 
            .HeaderText = "Horizontal Bar Spacing" 
            .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells 
            .SortMode = DataGridViewColumnSortMode.NotSortable 
            Dim cboHBSpacing As New DataGridViewComboBoxColumn 
            cboHBSpacing.Items.Add("1' 1/4" & Chr(34)) 
            cboHBSpacing.Items.Add("8" & Chr(34)) 
            dgModules.Columns.Insert(7, cboHBSpacing) 
        End With 
        With dgModules.Columns(8) 
            .HeaderText = "Vertical Bar Size" 
            .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells 
            .SortMode = DataGridViewColumnSortMode.NotSortable 
            Dim cboVBSize As New DataGridViewComboBoxColumn 
            cboVBSize.Items.Add("#5") 
            cboVBSize.Items.Add("#6") 
            cboVBSize.Items.Add("#7") 
            cboVBSize.Items.Add("#8") 
            dgModules.Columns.Insert(8, cboVBSize) 
        End With 
        With dgModules.Columns(9) 
            .HeaderText = "Vertical Bar Spacing" 
            .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells 
            .SortMode = DataGridViewColumnSortMode.NotSortable 
            Dim cboVBSpacing As New DataGridViewComboBoxColumn 
            cboVBSpacing.Items.Add("1' 1/4" & Chr(34)) 
            cboVBSpacing.Items.Add("8" & Chr(34)) 
            dgModules.Columns.Insert(9, cboVBSpacing) 
        End With 
End Sub- select from database
- read into a data table
- declare new dataset and place the
the data table in the dataset
- use the dataset to write an XML
file (conversion process takes place for some values in the dataset)
- declare a new dataset and read XML
file into the dataset (conversion process takes place for some values in the dataset)
- declare a new dataview and populate the
dataview with the current dataset
- assign the current dataview to the datagrid's
data source
- format the columns of the grid
			
				Last edited by a moderator: 
			
		
	
								
								
									
	
		
			
		
		
	
	
	
		
			
		
		
	
								
							
							 
	 
 
		 
 
		 
 
		 
 
		