|
Hello, I encounter strange phenomenon with my listview and smallimages. The images disappear and don't come back, even after reboot, run the application on a different machine. If i create a new listview, it works again for a while. Does anyone can help me with this annoying thing.
The imagelist has 2 images and when i replace the listview i reuse it. Here you have my code, first the declaration of the listview, and second, how i add during the program one element.
Thanks for to take a look into this.
Declaration:
'
'ListView2
'
Me.ListView2.AccessibleDescription = resources.GetString("ListView2.AccessibleDescription")
Me.ListView2.AccessibleName = resources.GetString("ListView2.AccessibleName")
Me.ListView2.Alignment = CType(resources.GetObject("ListView2.Alignment"), System.Windows.Forms.ListViewAlignment)
Me.ListView2.Anchor = CType(resources.GetObject("ListView2.Anchor"), System.Windows.Forms.AnchorStyles)
Me.ListView2.BackgroundImage = CType(resources.GetObject("ListView2.BackgroundImage"), System.Drawing.Image)
Me.ListView2.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.clh_1, Me.clh_2, Me.clh_3, Me.clh_4, Me.clh_5, Me.clh_6, Me.clh_7, Me.clh_8, Me.clh_9, Me.clh_10})
Me.ListView2.Dock = CType(resources.GetObject("ListView2.Dock"), System.Windows.Forms.DockStyle)
Me.ListView2.Enabled = CType(resources.GetObject("ListView2.Enabled"), Boolean)
Me.ListView2.Font = CType(resources.GetObject("ListView2.Font"), System.Drawing.Font)
Me.ListView2.FullRowSelect = True
Me.ListView2.GridLines = True
Me.ListView2.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable
Me.ListView2.ImeMode = CType(resources.GetObject("ListView2.ImeMode"), System.Windows.Forms.ImeMode)
Me.ListView2.LabelWrap = CType(resources.GetObject("ListView2.LabelWrap"), Boolean)
Me.ListView2.LargeImageList = Me.ImageList1
Me.ListView2.Location = CType(resources.GetObject("ListView2.Location"), System.Drawing.Point)
Me.ListView2.Name = "ListView2"
Me.ListView2.RightToLeft = CType(resources.GetObject("ListView2.RightToLeft"), System.Windows.Forms.RightToLeft)
Me.ListView2.Size = CType(resources.GetObject("ListView2.Size"), System.Drawing.Size)
Me.ListView2.SmallImageList = Me.ImageList1
Me.ListView2.TabIndex = CType(resources.GetObject("ListView2.TabIndex"), Integer)
Me.ListView2.Text = resources.GetString("ListView2.Text")
Me.ListView2.View = System.Windows.Forms.View.Details
Me.ListView2.Visible = CType(resources.GetObject("ListView2.Visible"), Boolean)
Add element with imageindex set on 0
Dim item As New ListViewItem("") ' 0
item.ImageIndex = 0
item.SubItems.Add("-") ' 1
item.SubItems.Add("-") ' 2
item.SubItems.Add("-") ' 3
item.SubItems.Add("-") ' 4
item.SubItems.Add("-") ' 5
item.SubItems.Add("0") ' 6
item.SubItems.Add("0") ' 7
item.SubItems.Add("0") ' 8
item.SubItems.Add("No") ' 9
Me.ListView2.Items.Add(item)
|
|
|
|
|
I don't immidiatly know why you're images disapear but I'd start by trying to figure out when exactly they disapear
(after a specific action or time)
also try triming you're code to the minimum (perhaps even rewrite some in a differant project and see if the same happens there)
since I'v never encountered this before (and I'v used listviews with images a few times before) I would think that somewhere in you're code there is a mistake that clears the images from the listview or the images from the imagelist
so I'm afraid this might be one of those trial and error debugging things
|
|
|
|
|
Do you think that all these lines are normal? For example: CType(resources.GetObject("ListView2.Dock"), System.Windows.Forms.DockStyle)
It is referring to the resources file, I am a C# programmer, but I have to make something in vb.net and in .NET 1.1, so I am using VS2003. I never saw this before.
Another, if I change the listview, i have images for a while and than it falls back to its old habit.
This sucks. I'll try to figure out what is causing this problem.
|
|
|
|
|
did you import you form or did you start from scratch, added the listview, set its properties,...?
it is possible that you get strange code like that from the designer when importing a form or when copying a control (I don't know why or how but it doesn't always work)
if you did copy it or import it I would suggest you make a new project and start from scratch there (not you whole prog just the bit with the lisview code) and see if you still have the behavior you described if so then something is probebly wrong with the code if you don't get that behavior and you copyed it or imported it then that is probably the reason
if you could providy more detail about all this I might be able to reproduce the behavior and help you further
|
|
|
|
|
Well what i do is i drag a listview from the toolbox on the form, set the options that i like one by one, and between I run my code in order to see where it goes wrong. And the conclusion is that i arrive to what I would like to have and the images are there.
In the meanwhile i am creating other classes, not really working on that form, and on a sudden debugging the images are disappearing. Pff, I don't know what is going on.
|
|
|
|
|
Then I'm afraid I'm at a lose aswel the code you pasted above shouldn't have been generated if you draged it from the toolbox (there should have been a very differant looking code)
all I can think of is recoding that part (delete the listview and put it back set its properys, name it the same as before so that you're code still works)
sorry I couldn't be more helpfull
|
|
|
|
|
Well, i am perplex myself also. I go to finish the application and recreate it from scratch, because i don't know what is going on. Damn, i wish i could program in VS2005
Thanks anyway for looking at my problem.
|
|
|
|
|
I want to pull data from two tables with a restriction on one field (only if a certain value). I want to then load into a dataset. Then be able to filter. Then offer user to change fields and write back to the database tables. What would be the best way to do this? I thought I could run a query to get the data in one table and then load into a dataset. But, it does not seem so easy to update the two tables. I am not familar with sql. Are there any articles you would suggest?
|
|
|
|
|
Cory Kimble wrote: But, it does not seem so easy to update the two tables. I am not familar with sql.
You're going to have to learn SQL in order to do this, or any other database related project. I highly suggest picking up a book on SQL Server 2005 and going through it. The book might come with SQL Server 2005 Express Edition (free), or you can download it from Microsoft.
If you write your query correctly, the DataAdapter object will fill a DataSet for you in as many DataTable and DataRelation objects as required.
|
|
|
|
|
I know how to use the hashtable. So far I have my program working by sending the forms to the hastable in code. Like so...
dim ptr as windows.forms.form
ptr = new frmOne
hashtable.add(ptr)
what I would like to do is replace the code above with code that will dynamically populate the hashtable, something to the effect of...
if projecttype\object\whatever is a system.windows.forms.form then
hashtable.add(projecttype\object\whatever)
I can't figure out how to do it
I tried using reflection.assembly.getexecutingassembly however a forms BaseType is not always stated as system.windows.forms.form it can also be the project namespace.formname, which completely negates the whole purpose of using it.
Ferron
|
|
|
|
|
I've got a bigger question. Why are you trying to do this at all?? What's the point of jumping through all these hoops?
|
|
|
|
|
I need to create a hashtable collection of all the forms in my project.
It needs to be done in code and it needs to be done without any user input.
It also needs to be able to be portable from one project to another without rewritting any code, so the list needs to be created dynamically.
Do u know how to achieve this, or can anyone point me in the correct direction?
Thanks
Ferron
|
|
|
|
|
ferronrsmith wrote: I need to create a hashtable collection of all the forms in my project.
It needs to be done in code and it needs to be done without any user input.
I'll ask again. Why??
|
|
|
|
|
Hello,
I have a VB.net Windows forms application that utilizes a rather large label control to display weights from a scale. My only problem is that I can't get the label.text alignment right. The text appears to go completely off the area that the label occupies. I've tried every setting for the "TextAlign" property. They all seem to go whack-o. Any ideas on what could be causing this bizarre behavior?
Thanks,
T-Tops
|
|
|
|
|
Is the label's AutoSize property set to False?
Other than that, there isn't sufficient information to tell you anything except how to label control works. How did you setup this label?? How long is the Text string?? Does it actually overflow the left, right side, or both sides, of the label? Are you looking for a single line of text to fit in the label as a single line?? Are you trying to break up the text so it occupies multiple lines in the label?
|
|
|
|
|
T-Tops wrote: They all seem to go whack-o
That makes the diagnosis very easy. You could Google that.
I'll try to give some ideas anyway:
Normal alignment is "TopLeft"; to right align choose "TopRight".
If you want to get a range of numbers at regular intervals (that is not an alignment issue!),
and you want to do that with just a single control, you should choose a "non-proportional"
font such as "Courier New".
If you want to be in charge of the label size, set AutoSize false.
If the text width exceeds the label width, text will wrap to the next line (and lacking
the necessary height it may be invisible).
If none of the above help you, try this:
- show the code
- give a decent description of what you get and what you want it to be
- for visual stuff, if possible, show an image
|
|
|
|
|
Hey guys, I have a question that I hope isn't too hard to get an anwser too, although even after all the Googling, and searching Code Project I've done I haven't had much luck yet.
What I'm trying to do is make a Datetime field in a SQL database null (it's already set to allow nulls), but no matter how many different ways I try I either get an error or the default lowest time is just filled in (1900/01/01 12:00:00 AM).
A time being there relys on the users input, so in some cases it might need to be filled in, in other cases it doesn't.
Anyway, here is my code, if anymore is needed just ask!
Dim DateClosed As Date
State = (ddlState.SelectedItem.Value)
If State = 0 Then
DateClosed = CDate(lstYear2.SelectedValue & "/" & lstMonth2.SelectedValue & "/" & lstDay2.SelectedValue)
Time = " " & ddlHour2.SelectedItem.Value + ":" + ddlMin2.SelectedItem.Value + ddlAMPM2.SelectedItem.Value
DateClosed += Time
Else
DateClosed = Nothing
End If
Just incase anyone needs to know, State is a drop down box with two selections. Open or closed. Open = 1 and Closed = 0.
Thanks,
aqzman
|
|
|
|
|
Well, this code doesn't have anything to do with SQL.
This only applies to VB.NET 2005 (.NET Framework 2.0) and above! It will NOT work with the .NET Framework 1.1 and below!
But, Date, which is just an alias for the DateTime type, normally cannot be Nothing, or null in C#. You'd have to declare it a special way to get it to work.
Dim myDate As New Nullable(Of DateTime)
myDate = New Date(2007, 7, 7)
If myDate.HasValue Then
' whatever you want if there is a value
Else
' myDate is Nothing, so...
End If
|
|
|
|
|
Hi,
Thanks a lot for the reply!
I've actually tried the As New Nullable(Of DateTime) code before, but there's a problem with that in other parts of my code. One part is where I use a '+' symbol it says "Operator '+' is not defined for types 'System.Nullable(Of Date)'" and it also causes an error on my SQL insert statement which is "Operator '&' is not defined for types 'String' and 'System.Nullable(Of Date)'."
I'm fairly new to VB.NET, SQL, and ASP.NET but those things seem to be almost totally unrelated as far as a nullable variable goes, guess not.
Oh, and just to let you know, I am using the .NET 2.0 framework.
Thanks again for the reply,
aqzman
|
|
|
|
|
aqzman_ wrote: I've actually tried the As New Nullable(Of DateTime) code before, but there's a problem with that in other parts of my code. One part is where I use a '+' symbol it says "Operator '+' is not defined for types 'System.Nullable(Of Date)'" and it also causes an error on my SQL insert statement which is "Operator '&' is not defined for types 'String' and 'System.Nullable(Of Date)'."
That's because you have to get the value out of the Nullable type before you can use it.
Dim myDate As Nullable(Of DateTime)
myDate = New Date(2007, 7, 7)
' myDate.Value returns a Date object, IF there is a value...
If myDate.HasValue Then
Debug.WriteLine("DATE: " & myDate.Value.ToShortDateString())
Else
Debug.WriteLine("DATE: Nothing")
End If
-- modified at 13:46 Monday 16th July, 2007
|
|
|
|
|
Thanks a lot for your help! I really appreciate it.
|
|
|
|
|
I am having a hard time finding good articles that show me how to do the following. I currently have data from a database table on my pc loaded in a dataset. I am currently binding that data to a datagrid. But, I want to be able to use dataviews so I can filter the data from the dataset. I have found nothing that gives you a step by step example of this. They only references DataTables, or how to create dataviews. Not how to create dataviews using datasets. Can anyone point me in the right direction.
|
|
|
|
|
I know this is a silly question, but have you looked around here?
I am not sure if this is one you might need, but it looks like you can pull info from it: http://www.codeproject.com/dotnet/filterdialog.asp[^]
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
|
Cool deal. Good luck with them
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|