|
Hello,
I Have a little trouble with the datagridview control
My code :
_Cmd.Connection = _DataConnectie
_Cmd.CommandText = Sql
_Adapt.SelectCommand = _Cmd
_DataTabel.Clear()
_Adapt.Fill(_DataTabel)
Grid.DataSource = _DataTabel
Grid.Refresh()
the datatable has 10 columns
Then I make an different Sql and want to display the result in the same grid, dut this time the result is 5 columns.
The Grid display's the 5 new columns but also the last 5 columns from the previous table
I have tried grid.columns.clear before filling the datatable en the binding but then de grid is empty
Can anyone help me
Thanks
|
|
|
|
|
Hi,
boss when u r trying to bind the resultset again to gridview, then u have to clear the data table or destroy the object of the table.
because it keeps previous queries results..
so u have to set null to datatable.
_DataTabel = null;
try it.
Abhishek Pareek
Software Engineer
Mumbai
|
|
|
|
|
Thanks
I Will try
But I already found that by setting _DataTabel = New Datatable it works !
|
|
|
|
|
Hi,
I have a created a user control (pagination for grid) in my application. It has four Imagebuttons. I need to trap the click event of these imagebutton outside of the user control and only in my aspx page. I am currently working on .Net 2.0.
Please show me the way,
Thanks,
|
|
|
|
|
You will have declare an event and raise it in the event which you want to capture e.g. if you have a button in your user control then you capture its click event as:
'Declare it in Declaration Section
Public Event MyButtonClicked()
'In the click event of button you will have to write this:
Private Sub cmdTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdTest.Click
RaiseEvent MyButtonClicked()
End Sub
MyButtonClicked() event will be available in aspx form and you can handle it.
hope you will get it if you face any problem let me know.
take care
Javed
|
|
|
|
|
Hey everyone, does any one know how I can convert a long or integer to it's corresponding binary representation in VB6 ? ... I tried the index ... it didn't help me out ..
Luay Al-wesi
|
|
|
|
|
A little Google goes a long way. Results[^] for "vb6 convert integer to binary string". The first link is pretty good.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
{vb .net 2003}
I'd like to add controls (specifically labels) to a form when its resized, to have the most number of labels possible that fit on the screen. I haven't had much luck finding a tutorial or code snippet that does this. Controls would be created using a for or while loop, so i need some way to easily create lots of them. I have the resize event down fine, its the dynamic creation that I'd like help on.
Thanks in advance,
BAM
|
|
|
|
|
bamnet wrote: have the most number of labels possible that fit on the screen.
bamnet wrote: create lots of them
Personally, I think that's a bad idea. the more controls you have on a form the longer it'll take to show - consider users with lower-end machines.
The code you'd be needing would look something like this (out my head)
Dim MyLabel As Label 'declare at modular level
Private Sub CreateLabels()
'create a new instance of a label
MyLabel = New Label
'add formatting, positioning, event handlers, etc. here
Me.Controls.Add(MyLabel) 'add the label to the form.
End Sub
You'll probably have to write functions to return values of how many labels you'll need as well as where to position them.
|
|
|
|
|
I don't have to consider users with lower end machines very much. The application is going to be used on one or maybe 2 machines maximum. The idea is to create a few labels on a panel on the lefthand side based on the screen resolution. In my previous draft of this program everything was hardcoded and changing the resolution and size of the application meant rewriting it. The most labels would be 10 max.. not too bad I think.
I've tried that code an I can't get it to display the label, I know the spot on the form is clear and set visible to true.
|
|
|
|
|
You added the labels to the form. They're probably sitting behind your panel control. Add them to the Panel's Controls collection instead.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I agree, I have to add them to the panel.
Me.PanelL.Controls.Add(newButton)
accomplished this task
|
|
|
|
|
The next part is doing this with a loop. I can create one element and add it to the panel, but how would I create x number of them?
|
|
|
|
|
Looping is easy, the problem I think you'll encounter is not adding more than one label but determining how many too add.
Modifying the code above slightly to demonstrate the loop -
Dim MyLabel As Label 'declare at modular level
'pass the value of the number of labels you'll need to
'the CreateLabels sub
Private Sub CreateLabels(ByVal NumberOfLabels as Integer)
Dim i As Integer
Do Until i = NumberOfLabels
'create a new instance of a label
MyLabel = New Label
'add formatting, positioning, event handlers, etc. here
Me.PanelL.Controls.Add(MyLabel) 'add the label to the panel
i += 1 'increment i so as to avoid an infinite loop
Loop
End Sub
|
|
|
|
|
Hi everyone:
While digging down into the ADO.NET side of VB.NET I came across a nice little bit of code that allows me to return the schema of a database table.
Code snippet:
Private Sub Table_Schema(ByVal strTbl As String)
'Retrieving schema for columns from a single table
Dim cmd As OleDbCommand = New OleDbCommand(strTbl, objConnection)
cmd.CommandType = CommandType.TableDirect
Try
'Retrieve schema only
objConnection.Open()
'Dim reader As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.SchemaOnly)
Dim reader As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.KeyInfo)
'Get references to schema information
Dim SchemaTable As DataTable = reader.GetSchemaTable()
'Close and release the connection before processing results
reader.Close()
objConnection.Close()
'Display schema table column headers
Dim col As DataColumn
SchemaTableList.View = View.Details
SchemaTableList.Clear()
For Each col In SchemaTable.Columns
SchemaTableList.Columns.Add(col.ColumnName, 100, HorizontalAlignment.Left)
Next
'Display Schema
Dim row As DataRow
Dim ColCount As Integer = SchemaTable.Columns.Count
For Each row In SchemaTable.Rows
Dim OrderDetails(ColCount) As String
Dim ColIdx As Integer
For ColIdx = 0 To ColCount - 1
OrderDetails(ColIdx) = Convert.ToString(row(ColIdx))
Next
Dim NewItem As ListViewItem = New ListViewItem(OrderDetails)
SchemaTableList.Items.Add(NewItem)
Next
Catch OleDbExceptionErr As OleDbException
'Display the error
MessageBox.Show(OleDbExceptionErr.Message, "Access SQL")
End Try
End Sub
The problem I have is; I don't need all that schema information. All I'm interested in is the Name of the Column, the datatype of the column and is it a primary column(field) or not.
In VB6 you could determine what information you wanted returned to you. My question is: Is there such a method available in VB.NET/ADO.NET? If so, How do you set it up for use?
Quecumber256
|
|
|
|
|
Hi
I am tryning to make aHi
I’m trying to make a program that prints out some text on a special location on a paper.
I’m using a Windows form, with some textboxes with a sender and resiver address.
Some combo boxes to determine a transport method, I made some text appear in a text box, when I check the combo box.
Example:
I check the box whose label is Taxi, and the word Taxi appears in a text box.
Then I made some buttons for the command printing, and for the command Exit (made a menu strip too, with the same functions).
My question then is how I can print this out.
I want to have the senders address on one location, and the resiver address on another location on the printed paper
And so on....
I’m using VB in visual studio 2005, and I’m going to print this out on a Oki Microline 520.
Ole Kr
A new beginner in VB.net
|
|
|
|
|
There are many ways to do what you ask...
Are you using a database to store information?
If so, it may have reporting features that you could use quite easily.
Would you consider Office automation, e.g. Word, Excel?
If so, you could simply create a Word template or Excel template and insert the data and print it from your code. This would require an installation of one of the above MS Office applications.
You could use Crystal Reports (if you have it).
Otherwise, you will need to work with Printer/Document objects, which could be quite difficult for someone new to VB.
Steve
|
|
|
|
|
Hii all,
I know this may seems to be a silly question but I need to know. Is it possible to delete an Executable file from itself. e.g I have an application, I want to delete its executable file from the code written in it.
Please reply.
Mubashir
|
|
|
|
|
No, you can't. The .EXE file remains locked open so long as the code in it is loaded into a process. You'll have to quit and have an external process delete this .EXE.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
is there a way that you could build an exe file into memory as a separate process and then have it wait for the parent process to die off and then delete it then end and kill itself from memory?
|
|
|
|
|
Well, you can load a new Assembly from an array of bytes, documented here[^]. The bytes can either be sourced from emitted code or from data in a file.
The problem is creating an entirely new Process out of that Assembly. I don't know how you can get from a loaded assembly to a whole new process.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi folks,
I'm in the process of writing an application to check for the existance of files and their sizes to replace a program we have at work which doesn't work (and which the source code has been lost).
Now I've recently started using Visual Basic 2005 Express Edition. I have a little bit of experience of VB6 but I'm struggling to get my head around the way some of the things are done in VB.Net.
The program is a console program which is supposed to sit in the background until a certain time and then start performing commands. I would like to add a couple of forms that can be used while the console application is running.
I found an example of code on a web site (can't remember the source sorry) which shows the form I want but then transfers execution to that form and stops running anything in the console window. The code I have is below...
<br />
Application.Run(New Form1())<br />
Now I would like the form to show on the screen and be active but also have things running in the background. I guess it would be classed as having two tasks running at once.
I'm just wondering if anyone knows how I can acheve this?
The idea is the end user can use things on the form while other tasks run on the console window in the background. At the moment though I can only have the console window doing something OR the form active, not both at the same time.
Sorry if this is a bit vague. I've spent the past hour searching Google but I can't seem to find anything obvious.
Could anyone suggest anything?
Regards,
Rob
|
|
|
|
|
You'd have to launch your forms on their own seperate threads. But, if you're going to use forms, you'd be better off starting from a Windows Forms app and including support for a console, instead of a Console app written trying to do forms.
It's easier to launch the Console portion of your app on it's own thread than it is to launch the Forms portion.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Ahh I see. Is it easy to open a console window from a Windows Forms app?
Thanks for the advice. Luckily I haven't got very far yet with the app so I'll start again with a new Windows Forms app.
Regards,
Rob
|
|
|
|
|
Try reading this[^] article for an example.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|