|
respected Gurus
i m making a windows application in vb.net.
here i m trying to bind a combobox from dataset.
but whenever i m trying to set the datasource property of my combobox,it jumps to the selectedindexchanged event for the combo box.
my code is as follows:-----------------
code to populate the combobox:---------------
Public Sub populateWebtype()
Try
cnSQL = New SqlConnection(ConnectionString)
Dim strSQL As String = "select webcode,webdesc from webmast"
cnSQL.Open()
cmSQL = New SqlCommand(strSQL, cnSQL)
cmSQL.CommandType = CommandType.Text
adpSQL = New SqlDataAdapter(cmSQL)
ds = New DataSet
adpSQL.Fill(ds)
Dim dr As DataRow
dr = ds.Tables(0).NewRow
'dr(valuemember) = ""
dr("webdesc") = "--Select--"
ds.Tables(0).Rows.InsertAt(dr, 0)
Me.cmbWebType.DataSource = ds.Tables(0).DefaultView 'AFTER THIS LINEJUMPS TO THE SELECTEDINDEXCHANGED
Me.cmbWebType.DisplayMember = "webdesc"
Me.cmbWebType.ValueMember = "webcode"
Me.cmbWebType.SelectedIndex = 0
cnSQL.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
selectedindexchangedevent of combobox:-----------
Private Sub cmbWebType_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbWebType.SelectedIndexChanged
Try
Dim webcode As Integer
webcode = cmbWebType.SelectedValue
strSQL = "select rmdesc as RawMaterial,Micron,Density,Gsm,Quantity as Norm from webnorm,webmast,rmmast where delete_flag <> 'Y' and webnorm.webcode = webmast.webcode and webnorm.rmcode = rmmast.rmcode And webnorm.webcode = " & webcode
cnSQL = New SqlConnection(ConnectionString)
cnSQL.Open()
cmSQL = New SqlCommand(strSQL, cnSQL)
cmSQL.CommandType = CommandType.Text
adpSQL = New SqlDataAdapter(cmSQL)
ds = New DataSet
adpSQL.Fill(ds)
DataGrid1.DataSource = ds.Tables(0).DefaultView
strSQL = "select distinct total_micron,total_gsm,total_quantity,sqmperkg from webnorm where delete_flag <> 'Y'And webnorm.webcode = " & webcode
cmSQL = New SqlCommand(strSQL, cnSQL)
Dim readSQL As SqlDataReader
readSQL = cmSQL.ExecuteReader
While readSQL.Read
If Not IsDBNull(readSQL("total_micron")) Then
txtTotalMicron.Text = readSQL("total_micron")
End If
If Not IsDBNull(readSQL("total_gsm")) Then
txtTotalGsm.Text = readSQL("total_gsm")
End If
If Not IsDBNull(readSQL("total_quantity")) Then
txtTotalQuantity.Text = readSQL("total_quantity")
End If
If Not IsDBNull(readSQL("sqmperkg")) Then
txtSqmPerKg.Text = readSQL("sqmperkg")
End If
End While
cnSQL.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
|
|
|
|
|
Setting the datasource DOES cause an index to become selected. If you don't want that, set a flag and check it in the event.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
thanks sir for ur quick reply
but sir how can i chk so that after setting the datasource it just go to the next statement in the event not to the selectedindexchanged
|
|
|
|
|
Set a class-scope flag (A boolean variable) to true just before you set the datasource of the ComboBox. In the SelectedIndexChanged event, check that flag. It it's set, reset the flag to false and don't do anything in the event handler. If it's false, then you do what you need to accomplish.
|
|
|
|
|
Hi Friend'z...
I need to know all the concepts of working with Strings in VB.Net
can any one help me?
thanks in advance...
|
|
|
|
|
Hi,
of course someone here can help you, but unless you ask a specific question nobody really knows where to start. For the beginning why don't you just read a book about vb.net?
|
|
|
|
|
|
I second the other persons advice, for you to ask such a broad question, indicates you need to read a book.
However, intellisense is also a great teacher, create a string, like
dim s as string = "I am still learning"
then type s. and all the methods of the string class will come up. You can also refer to the MSDN site ( msdn.microsoft.com ) for online documentation.
If you're concatenating lots of strings, use a stringbuilder, and if you need to do complex searching in strings, use regular expressions.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
i am usind VB.NET 2003 i want to get the data from dataset to excel sheet.How to do it.Please help me out.urgent
Mohinder Singh
|
|
|
|
|
|
can anyone explain clearly whether VB.net is platform independent or not? so many people saying their own style. still i am confused. TIA
|
|
|
|
|
I think java is platform independent .It can run on both windows as well as linux platform.unlike .net platform which runs only on windows.
|
|
|
|
|
Not true. .NET runs under Linux, using Mono. The difference is that there's a lot more Java VMs than there are .NET implimentations.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thank You Sir
What are mono?
and one more thing
so is it right to say that .net is platform independent?
|
|
|
|
|
Nilish wrote: What are mono?
One of those things that google knows all about.
Nilish wrote: so is it right to say that .net is platform independent?
Sort of. Like the OP said, it's hard to get a straight answer, because the answer is, anyone can write a .NET engine for any platform, but right now, the Mono people are doing it for Linux, and that's about it. I don't know how complete Mono is, but I think it's close to a complete .NET 1.1 implimentation.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
From what I can see from a look on their roadmap, everything (?) is up to 1.1, and most of 2.0 is implemented in most of the parts.
Anyhow, unless you have some very specific needs, it should be fully usable.
---
single minded; short sighted; long gone;
|
|
|
|
|
Please don't crosspost.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I would say at this point .NET is not platform independant, but has the protential of being so.
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
The .NET Framework is Microsoft's implementation of the Common Language Infrastructure specifications. Mono is a Linux implementation of the CLI, that also models itself after the .NET Framework.
Other than that, I don't know of any other implementations. Though anyone is free to implement their version of the CLI on any platform they choose.
|
|
|
|
|
can in add textboxes only in the first cell of datagridview?
I have four rows in the datagriddview.
|
|
|
|
|
You should add textboxes as you adding images in the datagridview
|
|
|
|
|
The textboxes do not appear as blinking cursors in the textboxes at runtime ?
Thet behave like labels . even readonlky property is false.
How can i make the the cursor to blink in the textboxes at runtime?
|
|
|
|
|
Of course you can do this.. just put a textbox into the grid during design time, and hide it during the form_load. write the code to make it visible, during runtime, when you click on the first column of the datagrid..
you must add the code to adjust the size of the textbox inorder to make it look like a cell in the datagrid..
The name is Sandeep
|
|
|
|
|
I am using the following code
Private Sub dg1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dg1.CellClick<br />
If (e.ColumnIndex = 2) Then<br />
TextBox1.Visible = True<br />
TextBox1.Left = 42<br />
TextBox1.Top = 19 * (Me.dg1.CurrentCell.RowIndex + 1)<br />
<br />
TextBox1.Height = dg1.CurrentRow.Cells(0).Size.Height<br />
TextBox1.Width = dg1.CurrentRow.Cells(0).Size.Width<br />
End If<br />
End Sub
as the row index increases , the coordinates flaws increases.
|
|
|
|
|
i was trying to add an image in the datagridview
i am using the following code
Dim column As DataGridViewColumn = New DataGridViewImageColumn<br />
column.HeaderText = "Image"<br />
dg1.Columns.Add(column)<br />
For count As Integer = 0 To dg1.RowCount - 1<br />
dg1.Rows(count).Cells(2).Value = Application.StartupPath & "\untitled.jpg"<br />
Next
I am doing right ??????????????????
|
|
|
|