Click here to Skip to main content
15,912,457 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionForm within a balloon or similar Pin
Dave McCool24-Jan-07 0:27
Dave McCool24-Jan-07 0:27 
QuestionDatagridView Pin
Socheat.Net24-Jan-07 0:13
Socheat.Net24-Jan-07 0:13 
AnswerRe: DatagridView Pin
Ahmed El-Badry24-Jan-07 1:06
Ahmed El-Badry24-Jan-07 1:06 
QuestionPlz help me Pin
Ahmed El-Badry24-Jan-07 0:07
Ahmed El-Badry24-Jan-07 0:07 
Questionhow to add comboBox as a column in DatagridView? Pin
priya_p23324-Jan-07 0:01
priya_p23324-Jan-07 0:01 
AnswerRe: how to add comboBox as a column in DatagridView? Pin
tonymathewt24-Jan-07 1:44
professionaltonymathewt24-Jan-07 1:44 
GeneralRe: how to add comboBox as a column in DatagridView? Pin
priya_p23324-Jan-07 18:15
priya_p23324-Jan-07 18:15 
AnswerRe: how to add comboBox as a column in DatagridView? [modified] Pin
atulks.in24-Jan-07 20:18
atulks.in24-Jan-07 20:18 
hi....
u can do this it worked for me
call this creategrid func from formload()
Public Sub creategrid()
'Declare and initialize local variables used
Dim dtCol As DataColumn = Nothing 'Data Column variable
'Create the String array object, initialize the array with the column names to be displayed
'arrstr = New String(9) {"Start Date", "End Date", "Start Time", "End Time", "Price", "Least Count", "Valid Days", "Remarks", "Booked slots", "Delete"}
arrstr = New String(8) {"Start Date", "End Date", "Start Time", "End Time", "Price", "Least Count", "Valid Days", "Remarks", "Booked slots"}
'Create the Data Table object which will then be used to hold columns and rows
dataTable = New DataTable("Controls")
'Add the string array of columns to the DataColumn object
Dim icnt As Integer
Try

For icnt = 0 To arrstr.Length - 1
Dim str As String = arrstr(icnt)
dtCol = New DataColumn(str)
dtCol.DataType = System.Type.GetType("System.String")
dtCol.DefaultValue = ""
dataTable.Columns.Add(dtCol)
Next icnt
If sAction = "Add" Then
Dim blrow As DataRow
blrow = dataTable.NewRow
dataTable.Rows.Add(blrow)
End If
'Set the Data Grid Source as the Data Table created above

dgAddInv.DataSource = dataTable
Dim cm As CurrencyManager
cm = CType(Me.BindingContext(dgAddInv.DataSource, dgAddInv.DataMember), CurrencyManager)
CType(cm.List, DataView).AllowNew = False
'set style property when first time the grid loads, next time onwards it will maintain its property
If Not dgAddInv.TableStyles.Contains("Controls") Then
'Create a DataGridTableStyle object
'Set its properties
dgdtblStyle.MappingName = dataTable.TableName
dgdtblStyle.RowHeadersVisible = True
dgAddInv.TableStyles.Add(dgdtblStyle)
Dim colStyle As GridColumnStylesCollection
colStyle = dgAddInv.TableStyles(0).GridColumnStyles
colStyle(8).ReadOnly = True
colStyle(8).NullText = "--New--"
'colStyle(1).Width = 220
'dgdtblStyle.RowHeadersVisible = False
dgdtblStyle.PreferredRowHeight = 22
dgdtblStyle.PreferredColumnWidth = dgdtblStyle.PreferredColumnWidth + 10
dgAddInv.BackgroundColor = Color.White
End If
'Take the text box from the second column of the grid where u will be adding the controls of your choice
datagridtextBox = CType(dgAddInv.TableStyles(0).GridColumnStyles(0), DataGridTextBoxColumn)
datagridtextBox1 = CType(dgAddInv.TableStyles(0).GridColumnStyles(1), DataGridTextBoxColumn)
datagridtextBox2 = CType(dgAddInv.TableStyles(0).GridColumnStyles(2), DataGridTextBoxColumn)
datagridtextBox3 = CType(dgAddInv.TableStyles(0).GridColumnStyles(3), DataGridTextBoxColumn)
datagridtextBox4 = CType(dgAddInv.TableStyles(0).GridColumnStyles(6), DataGridTextBoxColumn)
'for least count and price
datagridtextBox5 = CType(dgAddInv.TableStyles(0).GridColumnStyles(4), DataGridTextBoxColumn)
datagridtextBox6 = CType(dgAddInv.TableStyles(0).GridColumnStyles(5), DataGridTextBoxColumn)
Catch oexp As Exception
ShowMsgBoxErrorOk(oexp)
End Try
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''and then addd ur controls in mouse down event as below
Private Sub DGAddInv_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgAddInv.MouseDown
hitTestGrid = dgAddInv.HitTest(e.X, e.Y)
If Not (hitTestGrid Is Nothing) Then
If hitTestGrid.Type = DataGrid.HitTestType.Cell Then
dtp = New DateTimePicker
dtp.Dock = DockStyle.Fill
dtp.Cursor = Cursors.Arrow
dtp.Format = DateTimePickerFormat.Custom
dtp.CustomFormat = "MM/dd/yyyy"
dtp.ShowUpDown = False
For i = 0 To dataTable.Columns.Count - 1
sType = dgAddInv(0, i).ToString()
If hitTestGrid.Column = i Then
Select Case hitTestGrid.Column
'Add and show the control of ur choice
Case 0
datagridtextBox.TextBox.Controls.Add(dtp)
If dgAddInv.Item(hitTestGrid.Row, 0) <> "" Then
dtp.Value = CType(dgAddInv.Item(hitTestGrid.Row, 0), Date).ToShortDateString
End If
dtp.BringToFront()
End Select
End If
datagridtextBox.TextBox.BackColor = Color.White
Next i
end if

end if

end sub


see if that works for u ...u will have to change a bit as per your control as i am adding a datetime picker u can add a combo instead....


-- modified at 2:33 Thursday 25th January, 2007

" There are 10 types of people one who understands binary and one who don't................."

AnswerRe: how to add comboBox as a column in DatagridView? Pin
tonymathewt24-Jan-07 22:43
professionaltonymathewt24-Jan-07 22:43 
QuestionDatabase error Pin
lanache23-Jan-07 23:58
lanache23-Jan-07 23:58 
AnswerRe: Database error Pin
atulks.in24-Jan-07 19:49
atulks.in24-Jan-07 19:49 
GeneralRe: Database error Pin
lanache24-Jan-07 23:04
lanache24-Jan-07 23:04 
AnswerRe: Database error Pin
atulks.in25-Jan-07 0:11
atulks.in25-Jan-07 0:11 
QuestionDatabase error Pin
lanache23-Jan-07 23:47
lanache23-Jan-07 23:47 
AnswerRe: Database error Pin
Ahmed El-Badry24-Jan-07 0:39
Ahmed El-Badry24-Jan-07 0:39 
GeneralRe: Database error Pin
lanache24-Jan-07 22:20
lanache24-Jan-07 22:20 
QuestionIs this possible??????? Pin
FeRtoll23-Jan-07 22:52
FeRtoll23-Jan-07 22:52 
AnswerRe: Is this possible??????? Pin
IqbalVB25-Jan-07 20:03
IqbalVB25-Jan-07 20:03 
GeneralRe: Is this possible??????? Pin
FeRtoll28-Jan-07 23:21
FeRtoll28-Jan-07 23:21 
Questioncreating a batch file to generate dll from code files of vb6 and vb.net Pin
atulks.in23-Jan-07 22:19
atulks.in23-Jan-07 22:19 
AnswerRe: creating a batch file to generate dll from code files of vb6 and vb.net Pin
Ahmed El-Badry24-Jan-07 0:42
Ahmed El-Badry24-Jan-07 0:42 
GeneralRe: creating a batch file to generate dll from code files of vb6 and vb.net Pin
atulks.in24-Jan-07 19:41
atulks.in24-Jan-07 19:41 
QuestionFile Watcher Question Pin
FeRtoll23-Jan-07 21:37
FeRtoll23-Jan-07 21:37 
QuestionCustom control Textbox Pin
Vikash Yadav23-Jan-07 21:16
Vikash Yadav23-Jan-07 21:16 
AnswerRe: Custom control Textbox Pin
Christian Graus23-Jan-07 22:03
protectorChristian Graus23-Jan-07 22:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.