space between tabs in tabcontrol Dotnetbar VB.NET - vb.net

i am trying to make a new tab and my new tabs always have a space between them
im new to this site so i cant post pictures so heres a link to my issue http://i43.tinypic.com/rbbndk.png
heres my new tab code
Private Sub NewPageToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles NewPageToolStripMenuItem.Click
Dim newpage As TabItem = TabControl1.CreateTab("newpage")
Dim textb As New RichTextBox
Dim filename As New TextBox
Dim sw As New StreamWriter(siteloc & filename.Text & ".hsp")
Dim createb As New Button
'Set the contents of the page
textb.ReadOnly = False
textb.Multiline = True
textb.Dock() = DockStyle.Top
textb.Height = 338
newpage.Text = "NewPage"
filename.Text = "Untitled"
filename.Location = New Point(5, 342)
filename.Width = 220
createb.Location = New Point(232, 342)
createb.Text = "Submit page"
'Add the tab to the page
newpage.AttachedControl.Controls.Add(filename)
newpage.AttachedControl.Controls.Add(textb)
newpage.AttachedControl.Controls.Add(createb)
TabControl1.Tabs.Add(newpage)
'select the tab
TabControl1.SelectedTab = newpage
'add button handlers
AddHandler createb.Click, AddressOf createb_Click
End Sub
i looked all over for answers and found nothing. i havent changed anything in the propertys and i just installed dotnetbar.

CreateTab method already adds the newly created tab to Tabs collection (see docs for the method) so you are adding it twice. Remove this code: TabControl1.Tabs.Add(newpage)
Hope this helps.

Related

How to display a single Windows Explorer folder (that cannot be navigated away from) within a userform?

I would like to have a box within the userform display the contents of a single folder.
I would like the folder to display icons similar to how Windows Explorer does, and I would also like users to be able to drag icons from other windows into it (just like a real explorer window).
I decided to use a listview, and this will populate it with a bunch of lines of text for each file, but clicking on them does nothing and I cannot drag anything in. Also they don't have icons.
Any ideas?
Dim fileEntries As String() = Directory.GetFiles("C:\Windows\")
For Each fileName As String In fileEntries
ListView1.Items.Add(fileName)
Next
This MSDN article describes exactly how to do this. it even gets the icons, as you requested! It also uses a ListView, too! Enjoy!
As Jeremy said, you will still need to hook up event, if you want it to respond to click (or drag) events.
Private listView1 As ListView
Private imageList1 As ImageList
Public Sub ExtractAssociatedIconEx()
' Initialize the ListView, ImageList and Form.
listView1 = New ListView()
imageList1 = New ImageList()
listView1.Location = New Point(37, 12)
listView1.Size = New Size(161, 242)
listView1.SmallImageList = imageList1
listView1.View = View.SmallIcon
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.listView1)
Me.Text = "Form1"
' Get the c:\ directory.
Dim dir As New System.IO.DirectoryInfo("c:\")
Dim item As ListViewItem
listView1.BeginUpdate()
Dim file As System.IO.FileInfo
For Each file In dir.GetFiles()
' Set a default icon for the file.
Dim iconForFile As Icon = SystemIcons.WinLogo
item = New ListViewItem(file.Name, 1)
' Check to see if the image collection contains an image
' for this extension, using the extension as a key.
If Not (imageList1.Images.ContainsKey(file.Extension)) Then
' If not, add the image to the image list.
iconForFile = System.Drawing.Icon.ExtractAssociatedIcon(file.FullName)
imageList1.Images.Add(file.Extension, iconForFile)
End If
item.ImageKey = file.Extension
listView1.Items.Add(item)
Next file
listView1.EndUpdate()
End Sub

How To Get Icons For Pictures Files in vb.net

I Tried To Get Icons Of files system and display it in my list Box
But i got an empty icon For Picture Files
This Is My Code:
Public Sub ExtractAssociatedIconEx()
' Initialize the ListView, ImageList and Form.
listView1 = New ListView()
imageList1 = New ImageList()
listView1.Location = New Point(37, 12)
listView1.Size = New Size(161, 242)
listView1.SmallImageList = imageList1
listView1.View = View.SmallIcon
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.listView1)
Me.Text = "Form1"
' Get the c:\ directory.
Dim dir As New System.IO.DirectoryInfo(TextBox1.Text)
Dim item As ListViewItem
listView1.BeginUpdate()
Dim file As System.IO.FileInfo
For Each file In dir.GetFiles()
' Set a default icon for the file.
Dim iconForFile As Icon = SystemIcons.WinLogo
item = New ListViewItem(file.Name, 1)
' Check to see if the image collection contains an image
' for this extension, using the extension as a key.
If Not (imageList1.Images.ContainsKey(file.Extension)) Then
' If not, add the image to the image list.
iconForFile = System.Drawing.Icon.ExtractAssociatedIcon(file.FullName)
imageList1.Images.Add(file.Extension, iconForFile)
End If
item.ImageKey = file.Extension
listView1.Items.Add(item)
Next file
listView1.EndUpdate()
End Sub
How I Can Get Icons For picture Files ?
Thanks

how to separate visible form instances' locations

from a question here : Question
Dim forms As Collections.Generic.IEnumerable(Of frmMain) = Application.OpenForms.OfType(Of frmMain).Where(Function(frm) frm.Visible)
For Each f As Form In forms
f.Location = New Point(0, 0) ' set coordinate as needed
Next
UPDATE the above code gets all visible forms but since its generic, all the visible forms appear on one place..
let's say, I have 3 markers.. named camera1 camera2 camera3..
on Form_Load I will click those 3 markers, and a supposed video feed will appear (in this case, each with a new instance of form2)
this is my code in which does what I want, only problem is, I want it to be reusable for the future of dynamically adding more rather than this, predefined.
Dim f2c1 As New Form2
Dim f2c2 As New Form2
Dim f2c3 As New Form2
If f2c1.Visible = True Then
f2c1.Location = camera1.LocalPosition + New Point(20, -240)
End If
If f2c2.Visible = True Then
f2c2.Location = camera2.LocalPosition + New Point(20, -240)
End If
If f2c3.Visible = True Then
f2c3.Location = camera3.LocalPosition + New Point(20, -240)
End If
that code, is this.. If I click the marker, drag the map. video feed form2 stays with them.
I want it on a function or sub that will do this..
'Public Sub when I drag the map()
'every form visible
'will follow -- let's say, will follow what marker clicked them
ask me if you need anything.. thanks
I did some workaround
Dim mList As New List(Of String)
marker.ToolTipMode = MarkerTooltipMode.Always 'as an indetifier of each markers as
marker.ToolTipText = dtrow("MarkerName") 'I have added it to a for each
Try
For Each m In mList 'get items from the list
If item.ToolTipText = m Then 'check same name
Dim f As New Form2
With f
If .Visible = True Then
.Hide()
Else
.Show()
Dim p As New Point
p = item.LocalPosition + New Point(20, -240)
.Location = p 'after I click form will appear right next to them
.Text = m
End If
End With
Exit Sub
End If
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
this is still not the ideal thing that is on my mind, but this practically answers my question for the moment.

Dynamically load Tabpages and data into those tabpages

I ma new Learner. I am creating an application in Visual Basic and I need help to load dynamically data from database into my tabpages.
I want TabPages names to be "Category Names" (From Tbl_Category) and in each Tabpages i want buttons to be created and these buttons are each record from "Tbl_ItemDetails.
button name will be from "ItemSKU" column. and button image will be from "Item_Image" column.
i have searched a lot but couldn't do it. Please help me on this.
if you guys know any other way of doing it (without tabpages) please share. Thanks!
here are some codes which i tried.
1. image code is not working.
2. if i have more items on tabpages it does not show any scroll bar. so i can see only few button not all.
![enter image description here][1]
Private Sub AddProductsToTabbedPanel()
Dim i As Integer = 1
For Each tp As TabPage In TabControl1.TabPages
Dim filteredProduct As ObjectQuery(Of Tbl_ItemDetails) = New ObjectQuery(Of Tbl_ItemDetails)(("SELECT VALUE P FROM Tbl_ItemDetails AS P WHERE P.CatID = " + i.ToString), cse)
Dim flp As FlowLayoutPanel = New FlowLayoutPanel
flp.Dock = DockStyle.Fill
For Each tprod As Tbl_ItemDetails In filteredProduct
Dim b As Button = New Button
b.Size = New Size(100, 100)
b.Text = tprod.ItemSKU
' ''how can i get image on button. bellow code is not working
'b.BackgroundImage = tprod.Item_Image
'b.Image = tprod.Item_Image
b.Tag = tprod
AddHandler b.Click, AddressOf Me.UpdateProductList
flp.Controls.Add(b)
Next
tp.Controls.Add(flp)
i = (i + 1)
Next
End Sub
1: How the Image will work
a) If you only provide a pathname to an existing file
button.Image = New Bitmap("C:\temp\Info.bmp")
b) If you get a bytearray from your DB containing the bitmap
Dim byteArrayFromDB As Byte()
Dim memStream As System.IO.MemoryStream
Dim img As Image
memStream = New System.IO.MemoryStream(byteArrayFromDB)
img = Image.FromStream(memStream)
2: Scrollable FlowLayoutPanel
flp.AutoScroll = True

Loading the ImageList to ListView doesn't work as intended in vb.net 2010

I try to load images from ImageList to ListView and it works great... but when the form is load, the last image of ImageList doesn't appear.... I will call this procedure at the combobox selectedIndexChanged event and at the form load... when the form load, the last image from ImageList doesn't appear and when I click the combobox for several times, all of the images appear as intended... Any help?
Here is the code..
Private Sub LoadMenuItem()
lvItem.Clear()
Dim adptItem As New Restaurant_Management_SystemDataSetTableAdapters.ItemTableAdapter
Dim categoryID As Integer = cboccategory.SelectedValue
Dim dtItem As Restaurant_Management_SystemDataSet.ItemDataTable = adptItem.GetDataByCategoryID(categoryID)
lvItem.BeginUpdate()
For Each drItem As Restaurant_Management_SystemDataSet.ItemRow In dtItem.Rows
Dim ms As System.IO.MemoryStream = New System.IO.MemoryStream(drItem.ImageForItem)
Dim img As Image = System.Drawing.Image.FromStream(ms)
ImageList1.Images.Add(drItem.ItemID, img)
lvItem.Items.Add(drItem.ItemName.Trim, drItem.ItemID)
Next
lvItem.EndUpdate()
cboItem.ValueMember = "ItemID"
cboItem.DisplayMember = "ItemName"
cboItem.DataSource = dtItem
lvItem.Refresh
End Sub