|
Is there a way to highlight specific items within a combobox?
I tried this code:
cboItems.controls.item(2).background = color.yellow
The 2 would represent an individual item, in this case I knew there was an item at index# 2. Studio said that this was a null reference and I assume that the index "2" might be referring to something besides the collection of items in the combo box.
Anybody know if you can control the background colors of individual items within combobox?
|
|
|
|
|
you cannot access combobox\listbox items collection via using control collection. They r different things.
If u need colored items, Set DRAWMODE to OwnerDraw Fixed or Variable.
Look Here[^]
|
|
|
|
|
I am trying to add a TableLayoutPanel (programatically). Here's what I have so far:
Private Sub drawTableLayoutPanel()
Dim iColumns As Integer = uxColumnsTbar.Maximum ' Horizontal Trackbar
Dim iRows As Integer = uxRowsTbar.Maximum ' Vertical Trackbar
'
Dim oTLP As New TableLayoutPanel
oTLP.Location = New Point(0, 0)
oTLP.Size = New Size(500, 200)
oTLP.AutoScroll = True
oTLP.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink
oTLP.GrowStyle = TableLayoutPanelGrowStyle.AddRows
oTLP.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset
'
oTLP.ColumnCount = iColumns
For c As Integer = 0 To (iColumns - 1)
oTLP.ColumnStyles(c).SizeType = SizeType.Absolute ' Errors HERE with c=0
oTLP.ColumnStyles(c).Width = (1 / iColumns)
Next
'
oTLP.RowCount = iRows
For r As Integer = 0 To (iRows - 1)
oTLP.RowStyles(r).SizeType = SizeType.Absolute
oTLP.RowStyles(r).Height = (1 / iRows)
Next
'
oTLP.Update()
End Sub
The error I get is:
System.ArgumentOutOfRangeException was unhandled
Message="Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"
Which collection are they referring to? iColumns=6 and iRows=4 - this has been verified.
Thanks,
Karen
Nooobie to OOP and VB.Net 2005
|
|
|
|
|
Well, I've haven't used the TableLayoutPanel yet, but it looks like the TableLayoutPanel.ColumnStyles collection is empty. Just because you set the ColumnCount to whatever, doesn't mean that there are any ColumnStyle objects added to the ColumnStylesCollection your trying to index.
For c As Integer = 0 To (iColumns - 1)
Dim newColStyle = New ColumnStyle(SizeType.Absolute, 1/iColumns)
Next
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks Dave, that got me past the error message.
I still don't get a TableLayoutPanel Control on my at runtime, but I'll post a new message with an appropriate subject title.
Thanks again,
Karen
Nooobie to OOP and VB.Net 2005
|
|
|
|
|
Using VS2005 RC1, every time I create a project and add a reference to a DLL or control that resides on a different drive I get the following error either when attemting to run the program or when I first attempt to add the reference:
... Could not load file or assembly ... Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)
I'm an administrator-equivalent user and have full create/modify/destroy on both my local drives and all network volumes. This seems to be the case when I create the project on my local C: drive and attempt to add a reference to something on a network mapped drive and when I create the project on a network drive and attempt to add a reference to a DLL on my C:. I've made sure the "Copy Local" setting is TRUE on the reference so I'm clueless as to what is triggering the exception.
For example, I can create a project on my local drive, add a ref. to a DLL that's IN my project folder and run it, no problem. The DLL has no dependancies other than .NET runtime. I then copy the entire project folder up to the network and load it (no errors) run it and it dies trying to create the form with the error above (the form refecences the DLL to create a new object).
I've google'd both the error code and text and haven't found anything on MSDN/MSDN2 or anywhere else that explains this (at least in any terms an old VB programmer such as myself can understand). Can anyone enlighten me as to what the heck causes this, and more to the point, how it can be avoided in the first place?
Thanks!
|
|
|
|
|
I need help on functions using vb.net i'm doing a little prog on sorting this is for my vb.net. i need to create a function that holds the highest integer out of 3 and another function that holds the lowest integer out of 3. Can some one please help me
|
|
|
|
|
If that is all you need your function to do, then you can add a function procedure to any form or module:
Public Function MaxThree(byval Int1 as integer, byval Int2 as integer, byval Int3 as integer) as integer
If Int1 > Int2 then
if Int1 > Int3 then
MaxThree = Int1
Exit Function
End If
End If
If Int2 > Int3 Then
.....
End Function
This is an incomplete, very basic, example but I think you should get the idea from here.
|
|
|
|
|
try this:
lowestValue = Math.Min(Math.Min(value1,value2),value3)
and
highestValue = Math.Max(Math.Max(value1,value2),value3)
Thanks,
Karen
Nooobie to OOP and VB.Net 2005
|
|
|
|
|
Hi,
I have this problem of adding dates in a combobox say in this format dd/mm/yyyy please help me out!
|
|
|
|
|
Which version of VB are you using?
|
|
|
|
|
|
The following example will add the last 20 days to your ComboBox:
'Create a variable of type Date
Dim dt As Date
Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load
'Set the start date to 20 days ago
dt = Date.Now.AddDays(-20)
'Loop and add each date until it reaches today
Do While Not dt > Date.Now
'Increment the dates
dt = dt.AddDays(1)
'And add the dates to the ComboBox
cmbDate.Items.Add(dt.Date.ToShortDateString)
Loop
End Sub
I hope that helps.
(although having never used it, I am not 100% sure it will work in version 2002)
-- modified at 13:46 Sunday 23rd October, 2005
|
|
|
|
|
ListBox1.Items.Add(Format(Now.Date, "dd/MM/yyyy"))
|
|
|
|
|
Am I committing a major sin by asking a question here regarding VB6?
If so, please be gentle with me!
Using VB6, how do you determine the mac address of a network card?
db
Darryl Borden
Principal IT Analyst
dborden@eprod.com
|
|
|
|
|
|
hey guys Can we do the same through vb.net
if yes tell me also
abhinav
|
|
|
|
|
I have some javascript that detects a certain mimetype that is installed and it all works great in firefox and netscape but doesnt in IE is there any vbscript that will do the same but in IE
<script><br />
<br />
<br />
if (navigator.mimeTypes["video/psiv"]) { <br />
document.write("You have Already installed the plugin continue to next page!");<br />
window.location = "installed.html"<br />
<br />
}<br />
else { <br />
document.write("You need to install the plugin continue to next page!");<br />
window.location = "download.html"<br />
<br />
}<br />
<br />
</script>
|
|
|
|
|
hi,
i'm trying to store values from database into an array using datareader,
but i'm getting this exception:
system.NullRefernceException:Object Reference not set to an instance of an object
please help me
|
|
|
|
|
Post some code. Where in your code does it break. Which object is not initialized? That is where you will find the problem.
|
|
|
|
|
thanq for ur response
i got this,
problem is that my array was not initialized properly
now i got this.
now i've another problem ..
i posted this problem,its subject is "HOW TO ADD Values TO DATAGRID"
this is regarding adding data to already existing data in a datagrid
please try this
thanks in advance
|
|
|
|
|
I am trying to get the domain name from a client PC of the domain it is connected to.
"company.com.au"
Most code I find gets the domain name but not the full domain.
Any ideas would be great...
Thanks...
When people make you see red, be thankful your not colour blind.
|
|
|
|
|
What "connected to" are you refering to? Are you asking how to get the DNS suffix from the TCP/IP properties? A Windows domain? An Active Directory domain? ...?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I would like to get the AD domain string'
DC=company,DC=com,DC=au
Having trouble getting this so was hoping to get the
company.com.au and use string replace the "." with "DC="
Hope this makes sense...
I can pull from the reg on the DC but not on a client...
Thanks
When people make you see red, be thankful your not colour blind.
|
|
|
|
|
Couldn't you just lookup the machine name to get it's AD object, then look at that object's Parent property?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|