I've been messing with the DataGridView component and it's really quite cool what you can do with it. I have it working for the most part, apart from one thing. I can't seem to get filtering working. The code I have is fort testing purposes only, basically just to get to know how to work with the DGV. I did notice that bSource.SupportsFiltering was set to False and I have no idea how to change that.
Private Sub Dialog1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim bList As New System.ComponentModel.BindingList(Of ListItem)
Dim bSource As New BindingSource()
bSource.DataSource = bList
' ListItem has Name, ID and Important properties, which are String, Integer and Boolean
bList.Add(New ListItem("Item 1", 1, True))
bList.Add(New ListItem("Item 2", 2, False))
bList.Add(New ListItem("Item 3", 3, True))
bList.Add(New ListItem("Item 4", 4, False))
DataGridView1.DataSource = bSource
DataGridView1.ColumnHeadersVisible = False
' This makes sure that only 'Important' and 'Name' are shown and displayed
' in the correct order
DataGridView1.Columns(2).DisplayIndex = 0
DataGridView1.Columns(1).DisplayIndex = 1
DataGridView1.Columns(0).DisplayIndex = 2
DataGridView1.Columns(0).Visible = False
DataGridView1.Columns(2).Width = 20
DataGridView1.Columns(1).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
DataGridView1.GridColor = Color.White
DataGridView1.RowHeadersVisible = False
DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim bSource As BindingSource = DataGridView1.DataSource
bSource.Filter = "ID == 2"
Basically, to test the filter, I wanted to press a button and then apply the filter and have the DGV display only the results of my filter action. I am sure that once I get the hang of the filtering, I can implement it fully in my main app. Does filtering just not work when using a BindingList as your data backend?
You can't change the SupportsFiltering property. It's a readonly flag that tells you if the datasource the BS is bound to supports filtering. Since you're using a List, no, you can't do filtering. You have to use a data source that DOES support filtering, like a DataSet or DataTable, most likely fed data by an Access or SQL Server database.
Dave Kreskowiak Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
Easy. sender is passed as Object, which can be anything, including an object that doesn't have a Name property.
Test, then Cast sender to the object type you expect it to be, like Button in your code:
Private Sub SomeSub(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click
If TypeOf sender Is Button Then
Dim s As Button = DirectCast(sender, Button)
Select Case s.Name
' Do something
' Do something
' This should never happen, but then again...
Doing this isn't a good idea. Simply renaming a button can cause your code to fail and be pretty difficult to track the problem down. Break your button handlers in their own methods and you'll increase your codes maintainability.
Dave Kreskowiak Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
In VB6, it was relatively easy to create a form that would allow the user to access a context-specific help system with hitting the F1 key. All the programmer need do was place a number in the HelpContextID property of the form. Is there anything equivalent in VB.NET?
I am trying to graph the entire column in the datatable using ZedGraph.
I have found some code on the web and I have tried to modify it to fit my code and the datatable that I have created. Unfortunately it does not work , nor run. It gives me an error when I try to run my code. Can someone please help me resolve this error. this error is located when I try to display the XDataMember and YDataMember.
the error which I get is this:
An unhandled exception of type 'System.NullReferenceException' occurred in microsoft.visualbasic.dll
Additional information: Object variable or With block variable not set.
Here is the code that I have:
Private Sub CreateGraph_DataSource(ByVal ZG1 As ZedGraphControl)
iam creating a set up using the publish wizard.
iam using ini files in my project,as well as some html files also
my application checking the version number from a xml file in a web site.
when it is displaying login form after installing then it is giving unable to find xx.xml file.(xx.xml file is file from which iam checking the version number from a website)
it is also having some htm file also,once i include that xx.xml file and publish then it will displaying message abc.htm file unable to find
if any one can help
I have a Windows Service written in VB.NET 2005 that consists of an EXE, a private DLL and a shared DLL. I install the EXE and private DLL to the Application Folder and the shared DLL to the GAC. I am installing on a Windows Server 2003 system.
The installation worked fine (or appeared to) when the shared DLL was already in the GAC (because another application installed it there). The first time I tried to do the install on a system where the shared DLL was not in the GAC it failed with an error that indicated that a component was missing.
It appears that when the install has finished copying files and runs InstallUtil to install the EXE file as a Windows Service it fails because it can not find the shared DLL. If I copy the shared DLL to the GAC or the Application Folder prior to the install the error does not occur. If I install the shared DLL to the Application Folder instead of the GAC the error does not occur (except now other applications can not share the DLL). If I install the shared DLL to both the GAC and the Application Folder the error does not occur.
I have adopted the last workaround as a temporary fix but I would like to install a single copy of the shared DLL into the GAC.
Has anyone seen this issue before and/or know of a solution?
BTW The problem does not occur if the exe is not a Windows Service presumably because the installation is not attempting to load any application code during the install.
Maybe I read this wrong, but it seems like you think the installutil program is going to install the shared dll in the GAC? I am not sure why you would think this would happen. It would always assume it is there or in the application folder. Maybe I am missing something.
Here is some code that I wrote but I am not sure if it is right.
Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
Timer1.Enabled = True
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
Timer1.Enabled = False
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'Check if the event log exists
If Not Diagnostics.EventLog.SourceExists("MyService") Then
Diagnostics.EventLog.CreateEventSource("MyService", "Myservice Log")
EventLog.Source = "MyService"
'Write to the log
Diagnostics.EventLog.WriteEntry("MyService Log", "This is log on " & _
Private Sub SearchFiles(ByVal FileType As String)
Dim FilePath As String = "c:\"
Dim rootDi As New DirectoryInfo(FilePath)
Dim Di As DirectoryInfo
For Each Di In rootDi.GetDirectories
Am I using the code above correctly? I am trying to search for files using windows service in vb.net 2005. I want to be able to specify which file type I am searching for. Please help.
HI,(all in vb 6.0)
i have an dll with a form and some public functions. i add reference of this dll in new project and try to change the command button's picture from calling project.the function gets executed smoothly but i didn't get the result(change in
command button's image).
Any help or hint is greatly appericiated.
i tried using button.refresh but no output.
i also try to sendmessage api to change text using setwindotext and now i can change the caption of the button.
But i need to change the picture of button where i'm in trouble.
Please let me know any suggestion /links.
my project was working good but till when i change its icons ,its giving error when i press F5
Error 1 Unable to write to output file 'C:\Documents and Settings\Windows XP 2005\My Documents\Visual Studio 2005\Projects\*******\obj\Debug\*******.exe': The specified image file did not contain a resource section.
i got where is the problem....the problem occured when i change the icon of the application in "my project properties".
i tried alot to solve it but all in vain
someone know the solution?
-- modified at 11:24 Thursday 3rd May, 2007
Last Visit: 31-Dec-99 18:00 Last Update: 21-Apr-21 11:05