creating table at runtime in vb.net, image control doesnt have imageurl proerty - vb.net

i am creating a table in vb.net code (htmltable) with htmltablerows and htmltablecell. I gave on image control but thatr control cant have the .imageurl property, which i need cause i have a handler image.ashx which brings image from the database.
heres' the code -
TD = New HtmlTableCell
Dim img As New HtmlImage()
img.ID = "image_" & rd("ID")
img.Style.Add("width", "100px")
img.Style.Add("height", "100px")
img.ImageUrl = "Image.ashx?id=" & rd("ID")
on the last line, "img.ImageUrl" i get this error -
'ImageUrl' is not a member of 'System.Web.UI.HtmlControls.HtmlImage'
how do i fix this?

ImageUrl is a member of the System.UI.WebControls.Image control. By contrast, you are using the direct HtmlImage control which is rendered exactly as an img tag would be. You should use the Src property of the HtmlImage control instead.

Related

How to open a winform at same location and with same size of its parent in vb.net? Parent may be Winform or UserControl

Dim popCus As New PopCustomer()
popCus.StartPosition = FormStartPosition.Manual
popCus.Location = New Point(ctrList.Location)
popCus.Size = New Size(ctrList.Size)
popCus.ShowDialog()
Here ctrList is a UserControl's object and PopCustomer if a Winform.
I want open PopCustomer at same location and same size of ctrList.
The problem there is that the Location of the UserControl is relative to its own parent while for the form it's relative to the screen.
If you change this:
popCus.Location = New Point(ctrList.Location)
to this:
popCus.Location = ctrList.PointToScreen(Point.Empty)
then you'll get the effect you want. You can actually use the same code for a form so that means that you can write a single method with a Control parameter and then use that parameter to set the Location and Size of the new form. You can then call that method and pass either a form or a user control as an argument.

How to set a background color of a control in windows 8 store application

I am designing an application and had to instantiate controls via code. The problem is that I am unable to change the background color. I tried to look all over the internet, but no succes. I have contacted the Microsoft support service, but no succes either.
I read that you normally change a color by using System.Color or System.ColorHelper. Both are not accesible in the application.
So how to solve the following problem:
TextBox^ txtID = ref new TextBox();
txtID->Background = ?;
I have the solution, first make a brush object and set the color and assign that color to your controls background. I used the following:
SolidColorBrush^ myBrush = ref new SolidColorBrush(Windows::UI::Colors::Red);
TextBox^ txtID = ref new TextBox();
txtID->Background = myBrush;

using Class TextToolStripSeparator

Hi Imm trying to use the Class TextToolStripSeparator, as provided here.
How to add informative text to menu strip separator in vb.net or C#
I am having dificulty implementing the solution. I have placed the classes in and have created a separator but I can't seem to figure out how to place the text. I am using a dynamicaly created ContextMenuStrip in a datagridview from a right click.
Dim menu As ContextMenuStrip = New ContextMenuStrip
Dim NewSep1 As New TextToolStripSeparator
menu.Items.Add(NewSep1)
menu.Show(Me, pt.X, pt.Y)
when I tryto add text like menu.Items.Add(NewSep1("-test-")) I get an error:
Error 1 Class 'myprog.TextToolStripSeparator' cannot be indexed because it has no default property.
What am I doing wrong?
It looks like you need to set the seperator's .Text property.
Dim NewSep1 As New TextToolStripSeparator
NewSep1.Text = "-test-"
menu.Items.Add(NewSep1)

Image array help in Silverlight

I'm Back! And having more Silverlight issues (yay!)
I am trying to create an image array in Silverlight but the images are not appearing on the page. Here is my code:
Public imgImages(50) As Image
Public Sub Create_Image_Array()
Dim I As Integer
For I = 0 To 50
imgImages(I) = New Image
imgImages(I).SetValue(Canvas.LeftProperty, System.Convert.ToDouble(0))
imgImages(I).SetValue(Canvas.TopProperty, System.Convert.ToDouble(0))
imgImages(I).Name = "imgImages" & I
imgImages(I).Width = System.Convert.ToDouble(18)
imgImages(I).Height = System.Convert.ToDouble(18)
imgImages(I).Source = New BitmapImage(New Uri("/Resources/yellow2.png", UriKind.Relative))
imgImages(I).Visibility = Windows.Visibility.Visible
AddHandler imgImages(I).MouseLeftButtonUp, AddressOf ImageClickEventProc
Next I
End Sub
Public Sub Draw_Images()
For I = 1 To secObject.intNumberOfImages
imgImages(I).SetValue(Canvas.LeftProperty, System.Convert.ToDouble(secObject.Images(I).intPosX))
imgImages(I).SetValue(Canvas.TopProperty, System.Convert.ToDouble(secObject.Images(I).intPosY))
imgImages(I).Visibility = Windows.Visibility.Visible
Next I
End Sub
The image array is created when the page is navigated to and then the page requests location information from a server and once it has that information it sets the X and Y coordinates of the images. All that part works fine - that was apparently the easy part - All the coordinate information is received and stored in secObject, the data is there. The URI for the resource of the image is there and it is valid, I tested it with another image control on the page.
The problem is that the little images are not displaying. I have tried numerous ways of getting them to display. I have found code on Google that does almost the exact same thing that I am trying to do and it is written in a similar way just for non-arrayed images.
I also tried another suggestion, to use TranslateTransform to set the positions of the images. This did nothing.
Dim tt As New TranslateTransform
tt.X = secObject.Images(I).intPosX
tt.Y = secObject.Images(I).intPosY
imgImages(I).RenderTransform = tt
I also removed the background image on the screen thinking that maybe the images were rendering below the background, and that is not the case.
Am I missing something? I admit to being a Silverlight n00b...
Thanks
-RW
OK I finally figured it out... I needed to create add the controls to the canvas:
LayoutRoot.Children.Add(imgImages(I))

Dynamically Created LABEL Element not showing up in XUL application

I'm trying to dynamically create a set of labels in my XUL Runner application. I have an HBox like so:
<hbox class="upload-attachments"></hbox>
If I manually assign a label element to it like so:
<hbox class="upload-attachments"><label value="test" /></hbox>
It works fine. Also, when I query the object in Javascript I can access the test label.
When I try and create new label elements programmatically it fails. This is roughly what I am doing:
var attachments = view.query_first('.upload-attachments');
var label = view.ownerDocument.createElement('label');
label.value = "Some value."
attachments.appendChild(label);
var childCount = attachments.childNodes.length;
The query_first method is just a call to the Sly Query Selector engine and in other cases works fine. The childCount value is updating appropriately, and as I said, I can access and manipulate any labels I manually add to the hbox.
Thanks in advance,
Either append it with the attribute set, or set the property after inserting:
var label = view.ownerDocument.createElement('label');
attachments.appendChild(label);
label.value = "Some value."
-- or --
var label = view.ownerDocument.createElement('label');
label.setAttribute("value", "Some value.");
attachments.appendChild(label);
The reasoning being that, before the element was inserted, the property setters don't work.