|
Yeah it is!!
The way to do it, without the RTB is to represent the Text and formatting in a data structure behind the scenes, then render the visible version using that data. It then makes changing the font, or pieces of it, in sections very easy since you're not hunting for the changes in the font through out the text. The code would already know where to make the changes.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Now how would this translate into some hard code?
|
|
|
|
|
I haven't written anything like that. I just have a couple theories in my head about how I would approach the problem.
Storing the text seperate from the formatting gives you quick access to the formatting itself. Pointers between text segments and existing formatting objects in a collection would allow for reuse of the same formatting object to control the formatting of several segments of text.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Since quite sometime I am trying to figure out how to change backcolor of a particular column in datagridview.
CellPainting event does that but I do not want to use, is there any property available, which can be used easily?
Please suggest, Thanks in advance.
Thanks,
RajKat
|
|
|
|
|
In your column's DefaultCellStyle property, you can change the BackColor. For example:
' Somewhere in your code to setup your columns:
'
Dim newCol As New DataGridViewTextBoxColumn
With newCol
.DataPropertyName = "databaseTableColumnName"
.HeaderText = "My Column Header"
.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader
.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
.DefaultCellStyle.BackColor = Color.Blue
End With
DataGridView1.Columns.Add(newCol)
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hey Dave,
Thanks for the solution, I was really looking for it.
Can you also tell me how to change the backcolor of just one cell of a datagridview?
I do not know what the problem is but
datagridview.rows(0).cells(0).style.backcolor=color.gray
is not working for me.
If any alternative or solution is there then please let me know.
Thanks,
RajKat
|
|
|
|
|
That code should work fine, so long as the DGV is filled with data already.
RoundsGridView.Rows(0).Cells(0).Style.BackColor = Color.BurlyWood
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I have 2 DataGridView and I need them to scroll together. The first DataGridView has Scrollbars set to none and the second DataGridView is only displaying the Vertical scrollbar. I need the Sync. the second DataGridView's vertical scrollbar to move the first DataGridView's vertical position.
Private Sub _Scrolling(ByVal sender As Object, ByVal e As System.Windows.Forms.ScrollEventArgs)<br />
Dim g As DataGridView = CType(Me.MainTabControl.Controls.Find("Employee_times", True)(0), DataGridView)<br />
' need help tranfering the event to the first DataGridView<br />
End Sub
Thanks.
|
|
|
|
|
Well, there's an easy way and a hard way. We'll try the easy way first:
The easy way is to put both DGV's in a Panel control and turn scrolling on in the panel. Don't turn on scrolling in the DGV's and don't worry about how big they DGV get. Just let them grow as far as they want in the vertical direction. The panel will then take care of the scrolling for you.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
How simple was that. LOL I ended up with a work around using the..
gTime.SetBounds(0, (-gEmployee.VerticalScrollingOffset) + 11, gTime.Size.Width, gTime.Size.Height)
Thanks for the help. I've been wanting to contribute to the site with an article of some sort. So, I'm thinking of using parts of my current project with the multiple datagridviews and runtime creation of them and linking. As my first attempt at an article on the site.
Thanks again.
|
|
|
|
|
Hello,
Herebelow my need:
I want application1 is notified when the user click on the ok button of application2.
I don't know how to code application1, please help me.
sign
|
|
|
|
|
You would normally use .NET Remoting, but something tells me you don't have any control over application2. Meaning, you didn't write application2 and you don't have the source code for it - Correct?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I want an API in windows that change My file Type.
|
|
|
|
|
No such thing. Perhaps if you gave a detailed description of what you're doing, we can come up with a solution.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Does anyone have sample VB 2005 code that has a Treeview control that can sort nodes alphabetically?
I've been searching the internet for days, and I can't see any code that implements sorting.
I want to avoid putting all elements into a listview, sorting that, then adding items to the treeview from the listview because there will be thousands of items in each branch and performance could be seriously affected.
I know there's a TreeViewNodeSorter Method in the Treeview, but I can't figure out how to use it.
Any help appreciated.
Iain
|
|
|
|
|
The existing TreeView already supports custom sorting, so it's no wonder you can't find a replacement control.
The TreeViewNodeSorter is not a method, but a property. It's expecting an instance of a class that you write that implements the IComparer interface. All you're doing is supplying a method to compare two arguments (Nodes) that the Treeview wants you to compare, comparing them yourself, returning a value (-1, 0, or 1) that says in which order the first and second arguments relate to each other. For example:
Imports System.Collections
Public Class MyNodeSorter
Implements IComparer
<font color=green>' You MUST supply the code for the Compare method using this exact function header!!</font>
Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare
<font color=green>' All you do is compare the objects you get (they should always be TreeNodes).
' First, cast the Objects you get to TreeNodes.</font>
Dim x As TreeNode = CType(x, TreeNode)
Dim y As TreeNode = CType(y, TreeNode)
<font color=green>' Then compare the Text properties of each node. Since the String class already
' supplies a Comparer implementation that works on strings (duh!), just use that
' to do the work for you and return the value that it returns.</font>
Return String.Compare(x.Text, y.Text)
End Function
End Class
Docs on String.Compare(string, string) [^]
So, all you have to do is create an instance of this class and pass it to the TreeViewNodeSorter property, say in Form_Load, or in a "Sort" button click event handler:
TreeView1.TreeViewNodeSorter = New MyNodeSorter()
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
That's a clear explanation, I'll try it out. I'm new to VB 2005 - I never realised it would be so complicated. I thought the Treeview would have built in sort functionality; it seems very fundamental.
Thanks a lot for replying, much appreciated.
Iain
|
|
|
|
|
It doesn't have a built-in sort (most of the sorting options in the .NET Framework standard controls don't come with any kind of sort), but there is a reason for this. Since supplying a sort would lock you into using only the data types supported by that sort, it limits the possible uses and how you use a control.
All the controls in the .NET Base Class Library (BCL) that support sorting, do so through one of the ICompare interfaces. This give every control the ability to support custom sorting on ANY class! All you have to do is supply the little piece of code to compare the objects since only you would know how to compare them.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
How do i set the properties of the data environment connection and the command?
|
|
|
|
|
"data environment"?? What are you refering to? Something in VB6? What are you working with or trying to do?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
Can anybody help me!!!!!!
how to automate selection of radio buttons using vb.net.
I am using mshtml.htmldocument
Public Sub OpenDownloadDataPage(ByRef wbBrowser As SHDocVw.InternetExplorer)
Dim HTMLDoc1 As mshtml.HTMLDocument
Dim iHtmlCol As IHTMLElementCollection
Dim iHtmlEle As IHTMLElement
Dim str1 As String
Do
Loop Until Not wbBrowser.Busy
HTMLDoc1 = wbBrowser.Document
iHtmlCol = HTMLDoc1.getElementsByTagName("a")
' Press the anchor tag to open DownloadData page
For Each iHtmlEle In iHtmlCol
If Not iHtmlEle.outerText Is Nothing Then
If iHtmlEle.outerText.ToLower = "Download Data".ToLower Then
iHtmlEle.click()
Exit For
End If
End If
Next
'Select Radio Buttons
For Each iHtmlEle In iHtmlCol
If Not iHtmlEle.getAttribute("name") Is Nothing Then
str1 = iHtmlEle.getAttribute("name").ToString
If str1 = "KWH" Then
If iHtmlEle.outerHTML = " " Then
iHtmlEle.click()
Exit For
End If
End If
End If
Next
Do
Loop Until Not wbBrowser.Busy
End Sub
Satishk
|
|
|
|
|
I must get a date from SQL database but it is declared as varchar. I want to use it as date type in my vb .net application.
How can I convert the value from sql varchar to vb .net date?
It is stored as "2006-09-27" in the database.
|
|
|
|
|
just run the string through a split.
put it back together the way you need it it
use cdate
for example:
Dim myDate As String
myDate = strVal.Split("-")
Dim newVal as string
newVal=myDate(1) & "/" myDate(2) & "/" & myDate(0)
dim newDate as date= cDate(newVal)
|
|
|
|
|
Hello Everyone. i have done an application in vs2005 who reads some input from a barcode scanner, displays the string read by the barcode on a textbox, updates a database and shows the results on some datagridviews. the barcode scanner is attached to a COM port. my problem is that when i attempt to process the data read (using the SerialPort.DataReceived event), i get a cross thread invalid operation exception (it says it can't access the textbox, because it's a different thread from the one who created it). if i try to set the control.CheckForIllegalCrossThreadCalls property to false, i can write text on the textbox, but my application locks up as it tries to do other things as refreshing datagrids or showing other forms. Please understand i have very little knowledge of VB.NET 2005. is there a simple way to solve this? Thanks in advance.
~~~ From Milano to The Hague, easy as it goes ~~~
|
|
|
|
|
I solved the problem, i discovered the magic world of delegates. Thanks anyway to everyone who read this message and thought of a solution for me.
~~~ From Milano to The Hague, easy as it goes ~~~
|
|
|
|