|
Hi,
It seems you need to get a single value from the selected row, if this is what you want please try the following snippet:
If IsDBNull(dg.Rows(e.RowIndex).Cells(0).Value) Then
TextBox1.Text = "N/A"
Else
TextBox1.Text = dg.Rows(e.RowIndex).Cells(0).Value
End If
* dg = DataGridView
Note: Change 0 to the column index that you want to read from!
hope this helps
|
|
|
|
|
|
hi
normally to display an image image control is required. if we want it on picture button also we can have it.
i have a pic with .jpeg extension of 7mb size. i am trying to display the image in vb.net webform but it is not displaying. but the same pic when i tried in windows forms i used picturebox to display the same pic(it was displayed).
how to do it in webforms.
does the resizing the image does not solve the problem cause the pic is 7mb size.
how to dispaly this picture
there is no such thing as good or bad.
|
|
|
|
|
You could start by checking that the image is in RGB format rather than CYMK - windows can display both but the browser can only display images in RBG format.
|
|
|
|
|
I am making a custom control which inherits from panel. This Control contains a collection field which will build a collection of another control (which also inherits from panel) in the form of List(of T). So far i have created my items (the second panel object) and during design time can go into the collection editor and add multiple items, yet when i close the collection ediotor and reopen it, the items in the collection have disappeared or are not visible in the collection builder anymore.
|
|
|
|
|
if the collection editor is you're first custom control wich contains the list(of T) then this behavior is normal. since you have closed the control containing the collection the collection has been destroyed when you reopen it a new collection (empty) is created.
If you want to keep the items in the collection even after closing it you have 2 options:
1) you save it to a db or file
2) you put the collection (list(of T)) not in you collection editor but in the form that contains the collection editor and when you open the collection editor you then give the list to it (you can do this with a public shared property and a few other methods)
hope this helps
|
|
|
|
|
ok...i sought-of follow you, maybe i should rephrase what i'm actually trying to do. I'm basically trying to add lots of panels to one panel through a collection property. This collection property is: PanelItem is the second control and this property exists on the first control.
Dim p_Collection as List(Of PanelItem)<br />
<br />
Public Property Collection() As List(Of PanelItem)<br />
Get<br />
Return p_collection<br />
End Get<br />
Set(ByVal value As List(Of PanelItem))<br />
p_collection = value<br />
End Set<br />
End Property
Now, when, in design mode, i click the ... button in the collection property of the first control it opens a collection editor, to this i can add, panelitems. Once i have done this and i close it. I then reopen this editor and find that no objects are now in it, yet when i go to add a new one, the number appended to the end automatically begins at 1 past the last one i added previously.
So my questions are:
Why is this happening?
What methods,subs etc do i use without using a database?
How do i get it to function like the treeview Node Collection Editor or similar?
|
|
|
|
|
my first guess would be that you forgot to display the items already in the list. That would result in not being able to see the items but that they are there.
In the load of you're second control (the collection editor) you should put something like this:
if p_collection.count >0 then
for each p as panelitem in p_collection
'display it
next
end if
without more code I can't really be shure about it
if you want to store this collection even after you're application has shutdown you will have to use a database or file or you can look into serialisation (not shure if its spelled correctly )
I'm not familiar with the treeview node collection editor but I'll take a look at it on my break
|
|
|
|
|
no i'm not trying to store a collection after i've shutdown the application, i'm trying to achieve functionality similar to a treeview. Go into a new project and add a treeview to the form, then add to it's nodes property a few nodes, then close the collection editor of the treeview and reopen it, the nodes you added are available to be edited, this is what i'm trying to achieve.
|
|
|
|
|
Ok I took a look at it (first time I did it that way I always do it in code)
I would think that the way you do it should work. Can you provide me with the load of the collection editor or/and constructor. that way I can try to reproduce the error you have and search for a solution
|
|
|
|
|
well what i've already shown you is all i've done, it's not real complex, just two controls that inherit Panel and one has the property i've already shown, in this way it creates its own collecton editor without me having to do it manually, but i'm starting to think that i should be doing it manually, how would i go about that?
|
|
|
|
|
Ok I'v recreated you're problem I'll take a look at it on my break wich is in about 2hours and let you know
|
|
|
|
|
|
Just stumbled on to something. I can't keep myself from trying to solve this (don't know why )
Here is the problem: a panel hasn't got a collection property by default so the collection editor (wich only displays because the property is a list) doesn't know what to do with it.
At first glance I don't think you will be able to achieve that what you want with a panel. Perhaps inheriting from a treeview will work better or a listview. But whitout knowing what exactly this custom control has to accomplish I don't know wich will be better.
Another option is ofcourse to do everything manually but I can't help you with that (haven't done that) and it is probably going to be alot of work. You'll probably have to draw the control you'r self.
If you tell me what functionality you are trying to accomplish perhaps I can help you search for a way to do that
|
|
|
|
|
I just can't stop searching
but I found a possibilaty
to accomplish something like this you have to use a property that already exists in a standerd panel and the only one that exists is the controls property so in you first custom control change you're property to this:
Private p As List(Of mainsub)
Public Overloads Property controls() As List(Of mainsub)
Get
Return p
End Get
Set(ByVal value As List(Of mainsub))
p = value
End Set
End Property
you can change the name of p and of mainsub but not of the property. the property must be controls
if you do this the collection editor will work
hope this helps
-- modified at 5:24 Thursday 30th August, 2007
there still seems to be a problem when you run the prog I take another look at it on my break (really need to get back to work now;P)
|
|
|
|
|
WOW! You've been a great help, haven't had a chance to try this stuff yet and the one below looks helpful also, i agree, it's an annoying puzzle that you hope has a simple answer and wel...it might not but thankyou heaps.
|
|
|
|
|
The problem is that you've added items into the collection but it is not "saved" in the InitializeComponent() part of the computer generated code. It is not persisted.
Consider reading this:
http://www.codeproject.com/csharp/dzcollectioneditor.asp
and maybe this
http://www.codeproject.com/csharp/collcontrolsrichdes.asp
|
|
|
|
|
hi all
I don't know how I con unload form in the vb.net with destroy all objects
plz help me
thanks alot
bye
|
|
|
|
|
hi,
You can use Dispose method.
Regards,
Paramhans Dubey.
|
|
|
|
|
Firstly dont learn Programming from Scratch on Forums. you can buy a book in VB.net and Download some e-books. now if you were using vb6, then it will be
unload Form1
in Vb.net a form is a class. so you have to create an instance of a Class. lets say i have a Form named "myform"
if i was to destroy all objects, i will say.
Dim objForm1 As New Form1
objForm1.Dispose()
But please my friend, take my advice and buy a book.
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
|
|
|
|
|
Hi, anybody who knows how to highlight the first row of a listview after you populate the data from table? Thanks
-- modified at 1:20 Thursday 30th August, 2007
angel
|
|
|
|
|
Does
xxx.Items(0).Selected = True
(where xxx is your list view) not work?
|
|
|
|
|
Thanks Jayson. But it did'nt work
angel
|
|
|
|
|
Hi, I have a problem when loading an MDI child form. I have develop an application in vb2005. My windows application form was running fine from the past. But this morning when I try to load the form, its dipslay the following error:
System.InvalidOperationException was unhandled<br />
Message="An error occurred creating the form. See Exception.InnerException for details. The error is: Conversion from string "" to type 'Long' is not valid."<br />
Source="DIC Donor Database"<br />
StackTrace:<br />
at DIC_Donor_Database.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190<br />
at DIC_Donor_Database.My.MyProject.MyForms.get_frmDelProgBud()<br />
at DIC_Donor_Database.mdiDonorDb.mnuDelProgBud_Click(Object sender, EventArgs e) in C:\Documents and Settings\roathkanel\My Documents\Visual Studio 2005\Projects\DIC Donor Database\DIC Donor Database\mdiDonorDb.vb:line 57<br />
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)<br />
at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)<br />
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)<br />
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)<br />
at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)<br />
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)<br />
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)<br />
at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)<br />
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)<br />
at System.Windows.Forms.Control.WndProc(Message& m)<br />
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)<br />
at System.Windows.Forms.ToolStrip.WndProc(Message& m)<br />
at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)<br />
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)<br />
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)<br />
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)<br />
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)<br />
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)<br />
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)<br />
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)<br />
at System.Windows.Forms.Application.Run(ApplicationContext context)<br />
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()<br />
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()<br />
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)<br />
at DIC_Donor_Database.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81<br />
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)<br />
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)<br />
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()<br />
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)<br />
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)<br />
at System.Threading.ThreadHelper.ThreadStart()
Could anyone tell me what is the problem? And how could I solve the problem?
|
|
|
|
|
According to the error message it is a simple conversion error somewhere. Apparently some query or something, that runs in the load event of your form, is returning a null value, or an empty string. It should probably return a number.
The best thing to do is to run your app in debug mode, and set the break point at the load event of your app.
First thing that comes to mind however is that you need to check your data, or adapt a query with ISNULL() statements to return at least 0, because it has started throwing this error all of a sudden.
Good luck,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|