By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,543 Members | 2,085 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,543 IT Pros & Developers. It's quick & easy.

Record insert

P: 5
urgent!!!!!!! kindly please anyone help me.......
actualy i am newbe to vb.net

i need data to be inserted in to my table like this...

sitenm cdate wrknm nowrk totwg
tamiz palace 12/1/2007 Electrician 34 5100
tamiz palace 12/1/2007 Mason 5 900

instead my following code produces result like this..

sitenm cdate wrknm nowrk totwg
tamiz palace 12/1/2007 Electrician 34 5100
12/1/2007

only updating value of last row added.i don't know y data from first set of controls are not added?????????
__________________________________________________ _

Private Sub Badd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Badd.Click

If ind <> 35 Then
If temp >= 30 Then
Me.Panel2.Height = Me.Panel1.Height + 30
End If
Select Case ind
Case 0
Dim xy As DataRow = dtbsdtab.NewRow
dtbsdtab.Rows.Add(xy)

cbxcontrol1 = CType(CreateControls.MakeControl("ComboBox", 40, 175, controlLeft, controlTop + 3 + temp, "", "Cbx" & ind), ComboBox)
TextControl1 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 220, controlTop + 3 + temp, "0", "TB1" & ind), TextBox)
TextControl2 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 360, controlTop + 3 + temp, "0", "TB2" & ind), TextBox)
TextControl3 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 490, controlTop + 3 + temp, "0", "TB3" & ind), TextBox)
TextControl4 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft, controlTop + 3 + temp, "", "TB4" & ind), TextBox)
DTPcontrol1 = CType(CreateControls.MakeControl("DateTimePicker", 20, 60, controlLeft + 220, controlTop + 3 + temp, CStr(DTPdop.Value), "DTP1" & ind), DateTimePicker)

cbxcontrol1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
TextControl1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
TextControl2.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
TextControl3.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

DTPcontrol1.Format = DateTimePickerFormat.Custom
DTPcontrol1.CustomFormat = "dd/MM/yyyy"

Me.Panel2.Controls.Add(cbxcontrol1)
Me.Panel2.Controls.Add(TextControl1)
Me.Panel2.Controls.Add(TextControl2)
Me.Panel2.Controls.Add(TextControl3)
Me.Panel2.Controls.Add(TextControl4)
Me.Panel2.Controls.Add(DTPcontrol1)

DTPcontrol1.Value = DateValue(CStr(DTPdop.Value))
TextControl4.Text = CBxsite.SelectedItem.ToString

dtbsdtab.Columns("cdate").DefaultValue = Date.Today
cbxcontrol1.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "wrknm", True, DataSourceUpdateMode.OnPropertyChanged))
TextControl2.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "nowrk", True, DataSourceUpdateMode.OnPropertyChanged))
TextControl3.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "totwg", True, DataSourceUpdateMode.OnPropertyChanged))
TextControl4.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "sitenm", True, DataSourceUpdateMode.OnPropertyChanged))
DTPcontrol1.DataBindings.Add(New System.Windows.Forms.Binding("value", dtbsdtab, "cdate", True, DataSourceUpdateMode.OnPropertyChanged))



cbxcontrol1.TabIndex = tabi
tabi += 1
TextControl1.TabIndex = tabi
tabi += 1
TextControl2.TabIndex = tabi
tabi += 1
TextControl3.TabIndex = tabi
tabi += 1

Badd.TabIndex = tabi
tabi += 1
Bsub.TabIndex = tabi
tabi += 1
Bsave.TabIndex = tabi
tabi += 1
Bexit.TabIndex = tabi
tabi += 1

AddHandler cbxcontrol1.GotFocus, AddressOf cbxcon_created
AddHandler cbxcontrol1.SelectedValueChanged, AddressOf cbxcon_Selindch
AddHandler TextControl2.LostFocus, AddressOf txtbox_lostfocuss
AddHandler TextControl2.TextChanged, AddressOf txtbox_lostfocuss
AddHandler TextControl1.TextChanged, AddressOf txtbox_lostfocuss

ind = ind + 1
indi = ind
temp += 30
temp1 += 1


Case 1

Dim xyz As DataRow = dtbsdtab.NewRow
dtbsdtab.Rows.Add(xyz)

cbxcontrol12 = CType(CreateControls.MakeControl("ComboBox", 40, 175, controlLeft, controlTop + 3 + temp, "", "Cbx" & ind), ComboBox)
TextControl12 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 220, controlTop + 3 + temp, "0", "TB1" & ind), TextBox)
TextControl22 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 360, controlTop + 3 + temp, "0", "TB2" & ind), TextBox)
TextControl32 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 490, controlTop + 3 + temp, "0", "TB3" & ind), TextBox)
TextControl42 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft, controlTop + 3 + temp, "", "TB4" & ind), TextBox)
DTPcontrol12 = CType(CreateControls.MakeControl("DateTimePicker", 20, 60, controlLeft + 220, controlTop + 3 + temp, CStr(DTPdop.Value), "DTP1" & ind), DateTimePicker)

cbxcontrol12.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
TextControl12.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
TextControl22.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
TextControl32.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

DTPcontrol12.Format = DateTimePickerFormat.Custom
DTPcontrol12.CustomFormat = "dd/MM/yyyy"

Me.Panel2.Controls.Add(cbxcontrol12)
Me.Panel2.Controls.Add(TextControl12)
Me.Panel2.Controls.Add(TextControl22)
Me.Panel2.Controls.Add(TextControl32)
Me.Panel2.Controls.Add(TextControl42)
Me.Panel2.Controls.Add(DTPcontrol12)

dtbsdtab.Columns("cdate").DefaultValue = Date.Today
cbxcontrol12.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "wrknm", True, DataSourceUpdateMode.OnPropertyChanged))
TextControl22.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "nowrk", True, DataSourceUpdateMode.OnPropertyChanged))
TextControl32.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "totwg", True, DataSourceUpdateMode.OnPropertyChanged))
TextControl42.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "sitenm", True, DataSourceUpdateMode.OnPropertyChanged))
DTPcontrol12.DataBindings.Add(New System.Windows.Forms.Binding("value", dtbsdtab, "cdate", True, DataSourceUpdateMode.OnPropertyChanged))

DTPcontrol12.Value = DateValue(CStr(DTPdop.Value))
TextControl42.Text = CBxsite.SelectedItem.ToString

cbxcontrol12.TabIndex = tabi
tabi += 1
TextControl12.TabIndex = tabi
tabi += 1
TextControl22.TabIndex = tabi
tabi += 1
TextControl32.TabIndex = tabi
tabi += 1

Badd.TabIndex = tabi
tabi += 1
Bsub.TabIndex = tabi
tabi += 1
Bsave.TabIndex = tabi
tabi += 1
Bexit.TabIndex = tabi
tabi += 1

AddHandler cbxcontrol12.GotFocus, AddressOf cbxcon_created
AddHandler cbxcontrol12.SelectedValueChanged, AddressOf cbxcon_Selindch
AddHandler TextControl22.LostFocus, AddressOf txtbox_lostfocuss
AddHandler TextControl22.TextChanged, AddressOf txtbox_lostfocuss
AddHandler TextControl12.TextChanged, AddressOf txtbox_lostfocuss

ind = ind + 1
indi = ind
temp += 30
temp1 += 1


End Select

Else
MessageBox.Show("Reached maximum limit")
End If



End Sub
Dec 1 '07 #1
Share this Question
Share on Google+
5 Replies


P: 5
urgent!!!!!!! kindly please anyone help me.......
actualy i am newbe to vb.net

i need to produce result like this.....

sitenm cdate wrknm nowrk totwg
tamiz palace 12/1/2007 Electrician 34 5100
tamiz palace 12/1/2007 Mason 5 900



instead my following code produces o/p like this..

sitenm cdate wrknm nowrk totwg
tamiz palace 12/1/2007 Electrician 34 5100
12/1/2007

only updating value of last row added.i don't know y data from first set of controls are not added?????????



Private Sub Badd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Badd.Click

If ind <> 35 Then
If temp >= 30 Then
Me.Panel2.Height = Me.Panel1.Height + 30
End If
Select Case ind
Case 0
Dim xy As DataRow = dtbsdtab.NewRow
dtbsdtab.Rows.Add(xy)

cbxcontrol1 = CType(CreateControls.MakeControl("ComboBox", 40, 175, controlLeft, controlTop + 3 + temp, "", "Cbx" & ind), ComboBox)
TextControl1 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 220, controlTop + 3 + temp, "0", "TB1" & ind), TextBox)
TextControl2 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 360, controlTop + 3 + temp, "0", "TB2" & ind), TextBox)
TextControl3 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 490, controlTop + 3 + temp, "0", "TB3" & ind), TextBox)
TextControl4 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft, controlTop + 3 + temp, "", "TB4" & ind), TextBox)
DTPcontrol1 = CType(CreateControls.MakeControl("DateTimePicker", 20, 60, controlLeft + 220, controlTop + 3 + temp, CStr(DTPdop.Value), "DTP1" & ind), DateTimePicker)

cbxcontrol1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
TextControl1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
TextControl2.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
TextControl3.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

DTPcontrol1.Format = DateTimePickerFormat.Custom
DTPcontrol1.CustomFormat = "dd/MM/yyyy"

Me.Panel2.Controls.Add(cbxcontrol1)
Me.Panel2.Controls.Add(TextControl1)
Me.Panel2.Controls.Add(TextControl2)
Me.Panel2.Controls.Add(TextControl3)
Me.Panel2.Controls.Add(TextControl4)
Me.Panel2.Controls.Add(DTPcontrol1)

DTPcontrol1.Value = DateValue(CStr(DTPdop.Value))
TextControl4.Text = CBxsite.SelectedItem.ToString

dtbsdtab.Columns("cdate").DefaultValue = Date.Today
cbxcontrol1.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "wrknm", True, DataSourceUpdateMode.OnPropertyChanged))
TextControl2.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "nowrk", True, DataSourceUpdateMode.OnPropertyChanged))
TextControl3.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "totwg", True, DataSourceUpdateMode.OnPropertyChanged))
TextControl4.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "sitenm", True, DataSourceUpdateMode.OnPropertyChanged))
DTPcontrol1.DataBindings.Add(New System.Windows.Forms.Binding("value", dtbsdtab, "cdate", True, DataSourceUpdateMode.OnPropertyChanged))



cbxcontrol1.TabIndex = tabi
tabi += 1
TextControl1.TabIndex = tabi
tabi += 1
TextControl2.TabIndex = tabi
tabi += 1
TextControl3.TabIndex = tabi
tabi += 1

Badd.TabIndex = tabi
tabi += 1
Bsub.TabIndex = tabi
tabi += 1
Bsave.TabIndex = tabi
tabi += 1
Bexit.TabIndex = tabi
tabi += 1

AddHandler cbxcontrol1.GotFocus, AddressOf cbxcon_created
AddHandler cbxcontrol1.SelectedValueChanged, AddressOf cbxcon_Selindch
AddHandler TextControl2.LostFocus, AddressOf txtbox_lostfocuss
AddHandler TextControl2.TextChanged, AddressOf txtbox_lostfocuss
AddHandler TextControl1.TextChanged, AddressOf txtbox_lostfocuss

ind = ind + 1
indi = ind
temp += 30
temp1 += 1


Case 1

Dim xyz As DataRow = dtbsdtab.NewRow
dtbsdtab.Rows.Add(xyz)

cbxcontrol12 = CType(CreateControls.MakeControl("ComboBox", 40, 175, controlLeft, controlTop + 3 + temp, "", "Cbx" & ind), ComboBox)
TextControl12 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 220, controlTop + 3 + temp, "0", "TB1" & ind), TextBox)
TextControl22 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 360, controlTop + 3 + temp, "0", "TB2" & ind), TextBox)
TextControl32 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 490, controlTop + 3 + temp, "0", "TB3" & ind), TextBox)
TextControl42 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft, controlTop + 3 + temp, "", "TB4" & ind), TextBox)
DTPcontrol12 = CType(CreateControls.MakeControl("DateTimePicker", 20, 60, controlLeft + 220, controlTop + 3 + temp, CStr(DTPdop.Value), "DTP1" & ind), DateTimePicker)

cbxcontrol12.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
TextControl12.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
TextControl22.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
TextControl32.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

DTPcontrol12.Format = DateTimePickerFormat.Custom
DTPcontrol12.CustomFormat = "dd/MM/yyyy"

Me.Panel2.Controls.Add(cbxcontrol12)
Me.Panel2.Controls.Add(TextControl12)
Me.Panel2.Controls.Add(TextControl22)
Me.Panel2.Controls.Add(TextControl32)
Me.Panel2.Controls.Add(TextControl42)
Me.Panel2.Controls.Add(DTPcontrol12)

dtbsdtab.Columns("cdate").DefaultValue = Date.Today
cbxcontrol12.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "wrknm", True, DataSourceUpdateMode.OnPropertyChanged))
TextControl22.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "nowrk", True, DataSourceUpdateMode.OnPropertyChanged))
TextControl32.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "totwg", True, DataSourceUpdateMode.OnPropertyChanged))
TextControl42.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "sitenm", True, DataSourceUpdateMode.OnPropertyChanged))
DTPcontrol12.DataBindings.Add(New System.Windows.Forms.Binding("value", dtbsdtab, "cdate", True, DataSourceUpdateMode.OnPropertyChanged))

DTPcontrol12.Value = DateValue(CStr(DTPdop.Value))
TextControl42.Text = CBxsite.SelectedItem.ToString

cbxcontrol12.TabIndex = tabi
tabi += 1
TextControl12.TabIndex = tabi
tabi += 1
TextControl22.TabIndex = tabi
tabi += 1
TextControl32.TabIndex = tabi
tabi += 1

Badd.TabIndex = tabi
tabi += 1
Bsub.TabIndex = tabi
tabi += 1
Bsave.TabIndex = tabi
tabi += 1
Bexit.TabIndex = tabi
tabi += 1

AddHandler cbxcontrol12.GotFocus, AddressOf cbxcon_created
AddHandler cbxcontrol12.SelectedValueChanged, AddressOf cbxcon_Selindch
AddHandler TextControl22.LostFocus, AddressOf txtbox_lostfocuss
AddHandler TextControl22.TextChanged, AddressOf txtbox_lostfocuss
AddHandler TextControl12.TextChanged, AddressOf txtbox_lostfocuss

ind = ind + 1
indi = ind
temp += 30
temp1 += 1


End Select

Else
MessageBox.Show("Reached maximum limit")
End If



End Sub
Dec 1 '07 #2

P: 5
urgent!!!!!!! kindly please anyone help me.......
actualy i am newbe to vb.net

i need to produce result like this.....

sitenm cdate wrknm nowrk totwg
tamiz palace 12/1/2007 Electrician 34 5100
tamiz palace 12/1/2007 Mason 5 900



instead my following code producing o/p like this..

sitenm cdate wrknm nowrk totwg
tamiz palace 12/1/2007 Electrician 34 5100
12/1/2007

only updating value of last row added.i don't know y data from first set of controls are not added?????????



Private Sub Badd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Badd.Click

If ind <> 35 Then
If temp >= 30 Then
Me.Panel2.Height = Me.Panel1.Height + 30
End If
Select Case ind
Case 0
Dim xy As DataRow = dtbsdtab.NewRow
dtbsdtab.Rows.Add(xy)

cbxcontrol1 = CType(CreateControls.MakeControl("ComboBox", 40, 175, controlLeft, controlTop + 3 + temp, "", "Cbx" & ind), ComboBox)
TextControl1 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 220, controlTop + 3 + temp, "0", "TB1" & ind), TextBox)
TextControl2 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 360, controlTop + 3 + temp, "0", "TB2" & ind), TextBox)
TextControl3 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 490, controlTop + 3 + temp, "0", "TB3" & ind), TextBox)
TextControl4 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft, controlTop + 3 + temp, "", "TB4" & ind), TextBox)
DTPcontrol1 = CType(CreateControls.MakeControl("DateTimePicker", 20, 60, controlLeft + 220, controlTop + 3 + temp, CStr(DTPdop.Value), "DTP1" & ind), DateTimePicker)

cbxcontrol1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
TextControl1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
TextControl2.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
TextControl3.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

DTPcontrol1.Format = DateTimePickerFormat.Custom
DTPcontrol1.CustomFormat = "dd/MM/yyyy"

Me.Panel2.Controls.Add(cbxcontrol1)
Me.Panel2.Controls.Add(TextControl1)
Me.Panel2.Controls.Add(TextControl2)
Me.Panel2.Controls.Add(TextControl3)
Me.Panel2.Controls.Add(TextControl4)
Me.Panel2.Controls.Add(DTPcontrol1)

DTPcontrol1.Value = DateValue(CStr(DTPdop.Value))
TextControl4.Text = CBxsite.SelectedItem.ToString

dtbsdtab.Columns("cdate").DefaultValue = Date.Today
cbxcontrol1.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "wrknm", True, DataSourceUpdateMode.OnPropertyChanged))
TextControl2.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "nowrk", True, DataSourceUpdateMode.OnPropertyChanged))
TextControl3.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "totwg", True, DataSourceUpdateMode.OnPropertyChanged))
TextControl4.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "sitenm", True, DataSourceUpdateMode.OnPropertyChanged))
DTPcontrol1.DataBindings.Add(New System.Windows.Forms.Binding("value", dtbsdtab, "cdate", True, DataSourceUpdateMode.OnPropertyChanged))



cbxcontrol1.TabIndex = tabi
tabi += 1
TextControl1.TabIndex = tabi
tabi += 1
TextControl2.TabIndex = tabi
tabi += 1
TextControl3.TabIndex = tabi
tabi += 1

Badd.TabIndex = tabi
tabi += 1
Bsub.TabIndex = tabi
tabi += 1
Bsave.TabIndex = tabi
tabi += 1
Bexit.TabIndex = tabi
tabi += 1

AddHandler cbxcontrol1.GotFocus, AddressOf cbxcon_created
AddHandler cbxcontrol1.SelectedValueChanged, AddressOf cbxcon_Selindch
AddHandler TextControl2.LostFocus, AddressOf txtbox_lostfocuss
AddHandler TextControl2.TextChanged, AddressOf txtbox_lostfocuss
AddHandler TextControl1.TextChanged, AddressOf txtbox_lostfocuss

ind = ind + 1
indi = ind
temp += 30
temp1 += 1


Case 1

Dim xyz As DataRow = dtbsdtab.NewRow
dtbsdtab.Rows.Add(xyz)

cbxcontrol12 = CType(CreateControls.MakeControl("ComboBox", 40, 175, controlLeft, controlTop + 3 + temp, "", "Cbx" & ind), ComboBox)
TextControl12 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 220, controlTop + 3 + temp, "0", "TB1" & ind), TextBox)
TextControl22 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 360, controlTop + 3 + temp, "0", "TB2" & ind), TextBox)
TextControl32 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 490, controlTop + 3 + temp, "0", "TB3" & ind), TextBox)
TextControl42 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft, controlTop + 3 + temp, "", "TB4" & ind), TextBox)
DTPcontrol12 = CType(CreateControls.MakeControl("DateTimePicker", 20, 60, controlLeft + 220, controlTop + 3 + temp, CStr(DTPdop.Value), "DTP1" & ind), DateTimePicker)

cbxcontrol12.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
TextControl12.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
TextControl22.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
TextControl32.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

DTPcontrol12.Format = DateTimePickerFormat.Custom
DTPcontrol12.CustomFormat = "dd/MM/yyyy"

Me.Panel2.Controls.Add(cbxcontrol12)
Me.Panel2.Controls.Add(TextControl12)
Me.Panel2.Controls.Add(TextControl22)
Me.Panel2.Controls.Add(TextControl32)
Me.Panel2.Controls.Add(TextControl42)
Me.Panel2.Controls.Add(DTPcontrol12)

dtbsdtab.Columns("cdate").DefaultValue = Date.Today
cbxcontrol12.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "wrknm", True, DataSourceUpdateMode.OnPropertyChanged))
TextControl22.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "nowrk", True, DataSourceUpdateMode.OnPropertyChanged))
TextControl32.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "totwg", True, DataSourceUpdateMode.OnPropertyChanged))
TextControl42.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "sitenm", True, DataSourceUpdateMode.OnPropertyChanged))
DTPcontrol12.DataBindings.Add(New System.Windows.Forms.Binding("value", dtbsdtab, "cdate", True, DataSourceUpdateMode.OnPropertyChanged))

DTPcontrol12.Value = DateValue(CStr(DTPdop.Value))
TextControl42.Text = CBxsite.SelectedItem.ToString

cbxcontrol12.TabIndex = tabi
tabi += 1
TextControl12.TabIndex = tabi
tabi += 1
TextControl22.TabIndex = tabi
tabi += 1
TextControl32.TabIndex = tabi
tabi += 1

Badd.TabIndex = tabi
tabi += 1
Bsub.TabIndex = tabi
tabi += 1
Bsave.TabIndex = tabi
tabi += 1
Bexit.TabIndex = tabi
tabi += 1

AddHandler cbxcontrol12.GotFocus, AddressOf cbxcon_created
AddHandler cbxcontrol12.SelectedValueChanged, AddressOf cbxcon_Selindch
AddHandler TextControl22.LostFocus, AddressOf txtbox_lostfocuss
AddHandler TextControl22.TextChanged, AddressOf txtbox_lostfocuss
AddHandler TextControl12.TextChanged, AddressOf txtbox_lostfocuss

ind = ind + 1
indi = ind
temp += 30
temp1 += 1


End Select

Else
MessageBox.Show("Reached maximum limit")
End If

End Sub
Dec 1 '07 #3

P: 5
urgent!!!!!!! kindly please anyone help me.......
actualy i am newbe to vb.net

i need to produce result like this.....

sitenm cdate wrknm nowrk totwg
tamiz palace 12/1/2007 Electrician 34 5100
tamiz palace 12/1/2007 Mason 5 900



instead my following code producing o/p like this..

sitenm cdate wrknm nowrk totwg
tamiz palace 12/1/2007 Electrician 34 5100
null 12/1/2007 null null null

only updating value of last row added.i don't know y data from first set of controls are not added?????????

Expand|Select|Wrap|Line Numbers
  1. Private Sub Badd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Badd.Click
  2.  
  3.         If ind <> 35 Then
  4.             If temp >= 30 Then
  5.                 Me.Panel2.Height = Me.Panel1.Height + 30
  6.             End If
  7.             Select Case ind
  8.                 Case 0
  9.                     Dim xy As DataRow = dtbsdtab.NewRow
  10.                     dtbsdtab.Rows.Add(xy)
  11.  
  12.                     cbxcontrol1 = CType(CreateControls.MakeControl("ComboBox", 40, 175, controlLeft, controlTop + 3 + temp, "", "Cbx" & ind), ComboBox)
  13.                     TextControl1 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 220, controlTop + 3 + temp, "0", "TB1" & ind), TextBox)
  14.                     TextControl2 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 360, controlTop + 3 + temp, "0", "TB2" & ind), TextBox)
  15.                     TextControl3 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 490, controlTop + 3 + temp, "0", "TB3" & ind), TextBox)
  16.                     TextControl4 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft, controlTop + 3 + temp, "", "TB4" & ind), TextBox)
  17.                     DTPcontrol1 = CType(CreateControls.MakeControl("DateTimePicker", 20, 60, controlLeft + 220, controlTop + 3 + temp, CStr(DTPdop.Value), "DTP1" & ind), DateTimePicker)
  18.  
  19.                     cbxcontrol1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  20.                     TextControl1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  21.                     TextControl2.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  22.                     TextControl3.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  23.  
  24.                     DTPcontrol1.Format = DateTimePickerFormat.Custom
  25.                     DTPcontrol1.CustomFormat = "dd/MM/yyyy"
  26.  
  27.                     Me.Panel2.Controls.Add(cbxcontrol1)
  28.                     Me.Panel2.Controls.Add(TextControl1)
  29.                     Me.Panel2.Controls.Add(TextControl2)
  30.                     Me.Panel2.Controls.Add(TextControl3)
  31.                     Me.Panel2.Controls.Add(TextControl4)
  32.                     Me.Panel2.Controls.Add(DTPcontrol1)
  33.  
  34.                     DTPcontrol1.Value = DateValue(CStr(DTPdop.Value))
  35.                     TextControl4.Text = CBxsite.SelectedItem.ToString
  36.  
  37.                     dtbsdtab.Columns("cdate").DefaultValue = Date.Today
  38.                     cbxcontrol1.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "wrknm", True, DataSourceUpdateMode.OnPropertyChanged))
  39.                     TextControl2.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "nowrk", True, DataSourceUpdateMode.OnPropertyChanged))
  40.                     TextControl3.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "totwg", True, DataSourceUpdateMode.OnPropertyChanged))
  41.                     TextControl4.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "sitenm", True, DataSourceUpdateMode.OnPropertyChanged))
  42.                     DTPcontrol1.DataBindings.Add(New System.Windows.Forms.Binding("value", dtbsdtab, "cdate", True, DataSourceUpdateMode.OnPropertyChanged))
  43.  
  44.  
  45.  
  46.                     cbxcontrol1.TabIndex = tabi
  47.                     tabi += 1
  48.                     TextControl1.TabIndex = tabi
  49.                     tabi += 1
  50.                     TextControl2.TabIndex = tabi
  51.                     tabi += 1
  52.                     TextControl3.TabIndex = tabi
  53.                     tabi += 1
  54.  
  55.                     Badd.TabIndex = tabi
  56.                     tabi += 1
  57.                     Bsub.TabIndex = tabi
  58.                     tabi += 1
  59.                     Bsave.TabIndex = tabi
  60.                     tabi += 1
  61.                     Bexit.TabIndex = tabi
  62.                     tabi += 1
  63.  
  64.                     AddHandler cbxcontrol1.GotFocus, AddressOf cbxcon_created
  65.                     AddHandler cbxcontrol1.SelectedValueChanged, AddressOf cbxcon_Selindch
  66.                     AddHandler TextControl2.LostFocus, AddressOf txtbox_lostfocuss
  67.                     AddHandler TextControl2.TextChanged, AddressOf txtbox_lostfocuss
  68.                     AddHandler TextControl1.TextChanged, AddressOf txtbox_lostfocuss
  69.  
  70.                     ind = ind + 1
  71.                     indi = ind
  72.                     temp += 30
  73.                     temp1 += 1
  74.  
  75.  
  76.                 Case 1
  77.  
  78.                     Dim xyz As DataRow = dtbsdtab.NewRow
  79.                     dtbsdtab.Rows.Add(xyz)
  80.  
  81.                     cbxcontrol12 = CType(CreateControls.MakeControl("ComboBox", 40, 175, controlLeft, controlTop + 3 + temp, "", "Cbx" & ind), ComboBox)
  82.                     TextControl12 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 220, controlTop + 3 + temp, "0", "TB1" & ind), TextBox)
  83.                     TextControl22 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 360, controlTop + 3 + temp, "0", "TB2" & ind), TextBox)
  84.                     TextControl32 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft + 490, controlTop + 3 + temp, "0", "TB3" & ind), TextBox)
  85.                     TextControl42 = CType(CreateControls.MakeControl("TextBox", 20, 60, controlLeft, controlTop + 3 + temp, "", "TB4" & ind), TextBox)
  86.                     DTPcontrol12 = CType(CreateControls.MakeControl("DateTimePicker", 20, 60, controlLeft + 220, controlTop + 3 + temp, CStr(DTPdop.Value), "DTP1" & ind), DateTimePicker)
  87.  
  88.                     cbxcontrol12.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  89.                     TextControl12.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  90.                     TextControl22.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  91.                     TextControl32.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  92.  
  93.                     DTPcontrol12.Format = DateTimePickerFormat.Custom
  94.                     DTPcontrol12.CustomFormat = "dd/MM/yyyy"
  95.  
  96.                     Me.Panel2.Controls.Add(cbxcontrol12)
  97.                     Me.Panel2.Controls.Add(TextControl12)
  98.                     Me.Panel2.Controls.Add(TextControl22)
  99.                     Me.Panel2.Controls.Add(TextControl32)
  100.                     Me.Panel2.Controls.Add(TextControl42)
  101.                     Me.Panel2.Controls.Add(DTPcontrol12)
  102.  
  103.                     dtbsdtab.Columns("cdate").DefaultValue = Date.Today
  104.                     cbxcontrol12.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "wrknm", True, DataSourceUpdateMode.OnPropertyChanged))
  105.                     TextControl22.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "nowrk", True, DataSourceUpdateMode.OnPropertyChanged))
  106.                     TextControl32.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "totwg", True, DataSourceUpdateMode.OnPropertyChanged))
  107.                     TextControl42.DataBindings.Add(New System.Windows.Forms.Binding("Text", dtbsdtab, "sitenm", True, DataSourceUpdateMode.OnPropertyChanged))
  108.                     DTPcontrol12.DataBindings.Add(New System.Windows.Forms.Binding("value", dtbsdtab, "cdate", True, DataSourceUpdateMode.OnPropertyChanged))
  109.  
  110.                     DTPcontrol12.Value = DateValue(CStr(DTPdop.Value))
  111.                     TextControl42.Text = CBxsite.SelectedItem.ToString
  112.  
  113.                     cbxcontrol12.TabIndex = tabi
  114.                     tabi += 1
  115.                     TextControl12.TabIndex = tabi
  116.                     tabi += 1
  117.                     TextControl22.TabIndex = tabi
  118.                     tabi += 1
  119.                     TextControl32.TabIndex = tabi
  120.                     tabi += 1
  121.  
  122.                     Badd.TabIndex = tabi
  123.                     tabi += 1
  124.                     Bsub.TabIndex = tabi
  125.                     tabi += 1
  126.                     Bsave.TabIndex = tabi
  127.                     tabi += 1
  128.                     Bexit.TabIndex = tabi
  129.                     tabi += 1
  130.  
  131.                     AddHandler cbxcontrol12.GotFocus, AddressOf cbxcon_created
  132.                     AddHandler cbxcontrol12.SelectedValueChanged, AddressOf cbxcon_Selindch
  133.                     AddHandler TextControl22.LostFocus, AddressOf txtbox_lostfocuss
  134.                     AddHandler TextControl22.TextChanged, AddressOf txtbox_lostfocuss
  135.                     AddHandler TextControl12.TextChanged, AddressOf txtbox_lostfocuss
  136.  
  137.                     ind = ind + 1
  138.                     indi = ind
  139.                     temp += 30
  140.                     temp1 += 1
  141.  
  142.  
  143.             End Select
  144.  
  145.         Else
  146.             MessageBox.Show("Reached maximum limit")
  147.         End If
  148.  
  149.     End Sub
Dec 1 '07 #4

Expert 100+
P: 487
We canít do homework for you. Describe your problem detail and post the code only in problematic area. (Better avoid giving description in topic.)

where are you inserting data?
Dec 1 '07 #5

P: 5
We can’t do homework for you. Describe your problem detail and post the code only in problematic area. (Better avoid giving description in topic.)

where are you inserting data?
Actually i am dynamically adding controls,after controls are added only data that contained in last set of controls are in dataset.that is my problem
Dec 5 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.