|
hi,
i am new in vb.net, i not know how to use datatable in vb.net , what is usefull to me pls define with code it very help full to me. thanks
vipin paliwal
|
|
|
|
|
If all you want is an overview of the DataTable class, read the documentation[^] on it. If you're looking for something more specific, you'll have to ask a more specific question.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Okay guys...I'm new to VB.NET. In fact, the only experience I have is building ASP applications. I have an application I am planning to design no matter how long it takes. It's just something I have to prove to myself I can do. Plus, it will make my work easier if I can accomplish my goals with the application.
I'm using the free VB Express from Microsoft as well as SQL Express. I have described briefly what I want my application to do at my site, http://berrien.homeip.net/application.asp[^] . I have been reading up on OOP and I think I am understanding that pretty well and I have been reading a little on the .NET Framework. I know I have a lot to learn, but I would like to build this application along the way if any of you would be so kind to help me. Thanks guys.
|
|
|
|
|
What you have described there is commonly known as a Content Management System, or CMS. There are other similar things such as dotnetnuke which are used for maintaining a portal website.
Im not sure how much help you can get here, as this forum is specifically for code related queries.
|
|
|
|
|
what is the coding or basic structure of code that is used to make a remove button for a listbox, so that only teh selected item is removed not the entire list?
also how do you make the clear list remove all files in the list but one? like the name?
thanks
|
|
|
|
|
surfer.chic.robbie wrote: make a remove button for a listbox
Are you saying you want a delete button next to every item in a ListBox? Or just one button that deletes selected items in a ListBox?
surfer.chic.robbie wrote: also how do you make the clear list remove all files in the list but one
You can do this two ways. You can iterate through the list items deleting each item (you can't use For Each for this!!) and skip the one you want. Or you can just wipe out the entire list and recreate the one item you want to keep.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
just a button where something is selected in the listbox that when the remove button is pressed that only it gets removed form the list everything else stays.
|
|
|
|
|
Easy, but with a hidden gotcha. Each the index of each selected item is contained in the ListBox's SelectedIndicies property. All you have to do is go through this list using For/Next , NOT For Each/Next !!, and remove each item from the Items collection at the index listed in SelectedIndicies .
There's the catch though! You have to go through the SelectedIndicies backwards! If you don't, you'll end up with an IndexOutOfRangeException . This is because as you remove items from the ListBox, the size of the collection of Selectedindicies changes. Say you have 10 items selected. At the beginning of the For/next loop, you'll be counting from 0 to 9. But, after you remove the first item, the upper limit of the Selectedindicies collection will be 8, not 9. And so on until your loop, still counting to 9, passes the upper limit of the Selectedindicies collection.
Dim i As Integer
For i = ListBox1.SelectedIndices.Count - 1 To 0 Step -1
ListBox1.Items.RemoveAt(ListBox1.SelectedIndices(i))
Next
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I have a problem that is similar that I can not figure out. I am trying to pass an array of a structure to a C++ DLL...
DllExport TFXCAN_RETURNS TFXLibInstallPGNTable(PGNDesc *pDesc);
I have used the following code to declare the function.
<structlayout(layoutkind.sequential, charset:="CharSet.Ansi)"> _
Public Structure PGNDesc
Public i32PGN As Int32
Public u8GrpFunction As Short
Public i8GrpFunctionFieldNo As Short
Public i8InstanceFieldNo As Short
Public u8Priority As UShort
Public bDestGlobal As UShort
Public eProtocol As Integer
Public u8FieldCnt As UShort
Public pFieldList As IntPtr
Public i16DataByteCount As Int16
Public pPropQualifier As IntPtr
Public pMaskValue As IntPtr
End Structure
Public Class PGNComm
Public Declare Auto Function TFXLibPtrTest2 Lib "TFXCAN.dll" Alias "TFXLibPtrTest2" (ByRef PGNArray As PGNDesc, ByVal lIndex As Integer) As Integer
End Class
Here is the code to call the function:
Public Shared Sub Main()
Dim X As Integer = 10
Dim I As Integer, lResult As Integer
Dim oPGNDesc(3) As PGNDesc
For I = 0 To 2
oPGNDesc(I) = New PGNDesc
Next
For I = 0 To 2
With oPGNDesc(I)
.i32PGN = 100
.u8GrpFunction = 101
.i8GrpFunctionFieldNo = 102
.i8InstanceFieldNo = 103
.u8Priority = 104
.bDestGlobal = 105
.eProtocol = 106
.u8FieldCnt = 107
.pFieldList = VarPtr(X)
.i16DataByteCount = 109
.pPropQualifier = VarPtr(X)
.pMaskValue = VarPtr(X)
End With
Next
lResult = Teleflex.TFXLibPtrTest2(oPGNDesc, 0)
This obviously does not work. Any help you can give me would greatly be appreciated.
Ed Hunt, Jr.
|
|
|
|
|
Without seeing the C++ declaration of the structure, it's impossible to tell you if you got the field definitions correct. Also, most basic strucutures require you to prefix the VB.NET Structure specification with a StructLayout Sequential attribute, but that, of course, depends on the structure and the requirements of the function you're trying to pass it to. For example:
<StructLayout(LayoutKind.Sequential)> _
Public Structure PGNDesc
Public i32PGN As Int32
Public u8GrpFunction As Short
Public i8GrpFunctionFieldNo As Short
Public i8InstanceFieldNo As Short
Public u8Priority As UShort
Public bDestGlobal As UShort
Public eProtocol As Integer
Public u8FieldCnt As UShort
Public pFieldList As IntPtr
Public i16DataByteCount As Int16
Public pPropQualifier As IntPtr
Public pMaskValue As IntPtr
End Structure
Dave Kreskowiak
Microsoft MVP - Visual Basic
-- modified at 21:29 Wednesday 12th April, 2006
|
|
|
|
|
hi.
how i can update value of key in configuration file?!
i'm using vb.net 2005
123
|
|
|
|
|
|
NET Framework 2.0 allows updating configuration file
Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
Changing here
config.Save()
|
|
|
|
|
Whoops! I missed the "2005" part of his post. My bad!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I have filled a dataset with my customers ok, but I am running in to some problems when trying to create a multi coloumn combobox with the data set.
When I run the code below, I receive the message "Object reference not set to an instance of an object" at this for loop....
For Each drDSRow In ds.Tables("tblCustomer").Rows:
When I look into my CustomerDataset, I can see my table, and indeed it is called tblCustomer.
Here is what I am trying to accomplish:
'Retrieve the data into a DataSet:
Me.TblCustomerTableAdapter.Fill(Me.CustomerDataset.tblCustomer)
Dim drDSRow As DataRow
Dim drNewRow As DataRow
Dim ds As New DataSet
'Create and populate the DataTable to bind to the ComboBox:
Dim dt As New CustomerDataset.tblCustomerDataTable
dt.Columns.Add("Cust Name", GetType(System.String))
dt.Columns.Add("Cust Number", GetType(System.String))
'populate Datatable
For Each drDSRow In ds.Tables("tblCustomer").Rows
drNewRow = dt.NewRow
drNewRow("Cust Name") = drDSRow("Cust_Name")
drNewRow("Cust Number") = drDSRow("Cust_Number1")
dt.Rows.Add(drNewRow)
Next
'bind datatable to the combobox by setting the combobox's datasource property to the datatable.
Me.cboDealerSelector.DropDownStyle = ComboBoxStyle.DropDownList
With Me.cboDealerSelector
.DataSource = dt
.DisplayMember = "Cust_Name"
.ValueMember = "Cust_Number1"
'.SelectedIndex = 0
End With
Dim aIndex As Integer
With Me.cboDealerSelector
For aIndex = 0 To .Items.Count - 1
If CType(.Items(aIndex)(1), String).Trim = TextBox2.Text.Trim Then
.SelectedIndex = aIndex
Exit For
End If
Next
If aIndex >= .Items.Count Then .SelectedIndex = -1
End With
Any suggestions is greatly appreciated.
Thanks,
Rashar
-- modified at 15:41 Wednesday 12th April, 2006
|
|
|
|
|
Rashar wrote: When I look into my CustomerDataset, I can see my table, and indeed it is called tblCustomer.
Great! But that not what your code is referencing:
For Each drDSRow In ds.Tables("tblCustomer").Rows
doesn't have anythign to do with your CustomerDataset. You created a new empty DataSet object, called ds , but you never filled it with anything. So, yes, the Tables("tblCustomer") reference returns Nothing . Since you're now trying to access the properties, Rows count, of a Nothing object, it'll throw the "Object reference not set to an instance of an object" error you're seeing.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I'm displaying search results in a listview control and I want to highlight or at least make the searched text bold in the listview items and subitems. Can anyone help please?
Thanks,
Ruki
Ruki
|
|
|
|
|
You can't just highlight items, or parts of items, in the ListView. You're best option would be to create your own ListView that exposes this functionality, inheriting from the normal ListView class. You'll have to owner-draw the ListView items yourself. You can search the articles for "custom listview[^]" for examples.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
hi Dave,
Thanks for the input. I understand this has to be done using owner-draw, but I'm bit lost with this. Can U pls help?
cheers,
Ruki
|
|
|
|
|
I already did. Read the articles. Owner-drawing is a subject that takes up entire articles. Much too much information for a forum post.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I'm displaying search results in a listview control VB.Net and I want to highlight or at least make the searched text bold in the listview items and subitems. Can anyone help please?
Thanks,
Ruki
Ruki
|
|
|
|
|
I am trying to find a masked textbox(textbox with input mask capability) to be used in a web form. I find plenty of masked textbox for winform.
Thanks
Seeker55
Seeking that which expands the limit
|
|
|
|
|
How can I change a Cursor Image with the MouseEnter/MouseLeave event of a control? VB 6 used to have a Custom Image choice but I cannot find any such option with VB.NET.
Thanks
|
|
|
|
|
You still use the MouseEnter and MouseLeave events of the control. Then you just set the Cursor property to whatever you want:
Private Sub Button1_MouseEnter(blah, blah) Handles Button1.MouseEnter
Cursor = Cursors.Hand
End Sub
Private Sub Button1_MouseLeave(blah, blah) Handles Button1.MouseLeave
Cursor = Cursors.Default
End Sub
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave, Thanks for your response. If I wanted to change 'Cursor = Cursors.Hand' to an image of my choice I would have to load the Cursor=Cursor.(from a file location "C:\Icons\MyChoice.ico)?
Pete
|
|
|
|