|
How do you customize a label control so that I can change the border color? I have searched high and low for examples/samples for a "label" control but found absolutely nothing.
Should I create my own label control from scratch?
-- Thanks!
|
|
|
|
|
Override the OnPaint event, like so:
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class MyLabel : Label
{
private Color borderColor;
public MyLabel()
{
InitializeComponent();
borderColor = Color.Black;
}
public Color BorderColor
{
get { return borderColor; }
set { borderColor = value; }
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawRectangle(new Pen(borderColor),
new Rectangle(0, 0, Width - 1, Height - 1));
}
}
}
|
|
|
|
|
Thank you very much for getting back to me on this so quickly.
|
|
|
|
|
I tried this out and it works great. Thanks again.
|
|
|
|
|
hi everybody,
I don't really use treeviews at all, but I need to for my current prototype. ...What I really need is a nested treeview (treeview as a treenode) and I can't find any usage guidelines for adding a treeview to the treeview.Nodes collection....is it as simple as filling out an 'inner' treeview and adding it to 'outer' treeview's Nodes collection?
...or am I going to have to extend the TreeView?
btw...VS 2003, not 2005
(Nyquist_Rate || ! Nyquist_Rate)
{
Console.WriteLine("That is the question");
}//Go Colts
|
|
|
|
|
You can't directly add a treeview to another one. If you knew your 2nd treeview had only 1 root node then do something like:
treeView1.SelectedNode.Nodes.Add(treeView2.Nodes[0]);
If there are multiple top level nodes then do:
foreach (TreeNode node in treeView2.Nodes)
{
treeView1.SelectedNode.Nodes.Add(node);
}
|
|
|
|
|
ok..here's my problem. I'll provide code:
The indexer for which dataset to display in the treeview is controlled by the selected Index of a listview
if(lvwDisplay.SelectedIndices.Count > 0)
{
index = lvwDisplay.SelectedIndices[0];
UIAddress location = (UIAddress)myAddressList[index];
Now I create the structure in the treeview to allow the PointsOfInterest to be
deserialized from my collection
for(int asdf = 0; asdf < location.PointsOfInterest.Length; asdf++)
{
TreeView inner = new TreeView();
inner.Name = location.PointsOfInterest[asdf].Name;
inner.Nodes.Add(location.PointsOfInterest[asdf].Fee.ToString());
TreeView gps= new TreeView();
gps.Name="Geocode";
gps.Nodes.Add(location.PointsOfInterest[asdf].Center.X.ToString());
gps.Nodes.Add(location.PointsOfInterest[asdf].Center.Y.ToString());
.
.
.
PROBLEM: ...you'll see it
tvPOI.Nodes = new TreeNodeCollection[location.PointsOfInterest.Length];
tvPOI.SelectedNode = tvPOI.Nodes[asdf];
for(int i = 0; i<geocode.Nodes.Count;i++)
{
tvPOI.SelectedNode.Nodes.Add(geocode.Nodes[i]);
}
...tvPOI.SelectedNode is readonly. Anybody know how to implement the functionality I'm trying to add?
(Nyquist Rate || ! Nyquist Rate)
{
Console.WriteLine("That is the question");
}
|
|
|
|
|
SelectedNode has a get and a set so you can set it, but I think you're trying to select a node that hasn't been added to the Collection yet.
tvPOI.Nodes.Clear();
for (
{
tvPOI.Nodes.Add(
}
tvPOI.SelectedNode =
|
|
|
|
|
My error in my last post:
tvPOI.Nodes = new TreeNodeCollection[location.PointsOfInterest.Length];
tvPOI.SelectedNode = tvPOI.Nodes[asdf];
for(int i = 0; i
{
tvPOI.SelectedNode.Nodes.Add(geocode.Nodes[i]);
}
I shoulda said that tvPOI.Nodes is read only...not tvPOI.SelectedNodes
(Nyquist Rate || ! Nyquist Rate)
{
Console.WriteLine("That is the question");
}
|
|
|
|
|
ok...think I got it. I just changed
tvPOI.Nodes = new ...
to
tvPOI.Nodes.Add("sdalfkjglasdkfh");
and everything was kosher.
(Nyquist Rate || ! Nyquist Rate)
{
Console.WriteLine("That is the question");
}
|
|
|
|
|
Im using sql server 2005 and trying to connect to a remote database, but i get the error "SQL Server does not exist or access denied".
There is not problem with the code and it has worked many times on other projects and will connect to the database when run locally.
The database has also been setup to accept remote connections, but i still cannot get a connection.
Any ideas?
Thanks for any help.
|
|
|
|
|
|
Yes, just though i would build some suspence before i asked it.
|
|
|
|
|
ednrgc wrote: Is there a question?
Does "Any ideas?" not count?
|
|
|
|
|
When I posted my reply, there was absolutely nothing in the original post. Hence my asking if there was a question.
|
|
|
|
|
ednrgc wrote: When I posted my reply, there was absolutely nothing in the original post. Hence my asking if there was a question.
Ah... That makes sense. It also seems to be intermittent whether the post is marked as "Modified" or not. (Perhaps because the poster can remove that text if they wish)
|
|
|
|
|
Have you checked the firewall between the computers. It might be blocking the port.
|
|
|
|
|
Windows firewall is turned off and there is no other firewall in-between the boxes.
|
|
|
|
|
wheelerbarry wrote: Windows firewall is turned off and there is no other firewall in-between the boxes.
Has the server been configured to use a different port?
Can you get Enterprise Manager/ SQL Management studio / Query Analyzer to connect?
|
|
|
|
|
Can you connect with VS. If so you could verify the connection strings via vs.
_____________________________________________________________________
Our developers never release
code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
Visit Me at GISDevCafe
|
|
|
|
|
Connecting to SQL Server 2005 (and Express) has one slight difference in how you point to the sql server.
In previous versions you would say the server's ip or name when requested (i.e. localhost or (local))
but it 2005, you need to put the server and the sqlserver (i.e. localhost/sqlserver)
In Sql Server 2005 Express, point to it using ".\sqlexpress"
Although i didn't quite understand what you are trying to do, or how, i hope this helped.
Ericos Georgiades
|
|
|
|
|
Hi folks!
I just came across a nasty problem I don't have a solution for.
When you have a selection in a textbox/richtextbox you can only query the start and length of the selection (SelectionStart , SelectionLength ). SelectionStart is always the left margin of the selection and SelectionLength is always >= 0.
Unfortunately, that way it's impossible to tell in which direction the selection has been created: Left to right or right to left.
In most cases this is not a problem but I want to adjust the selection exactly the way it can be done using Shift+Cursor Left/Right. With this combination you can always move the end of the selection around, even when the end of the selection is left of the selection start.
I've even tried using EM_GETSEL to retrieve the start and end of the selection, but - just as SelectionLength is always >= 0 - the selection start is always <= the selection end
Does anyone have an idea how to get to this extra information?
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
You have this functionality by default on the textbox...
I don't see why you need to be able to set SelectionStart and Length from both directions. If you're doing a Shift+Left on a KeyDown event handler why not just do:
textBox1.SelectionStart--;
textBox1.SelectionLength++;
|
|
|
|
|
I need to adjust the selection as a reaction to button presses on special input devices (a footswitch or a hand-held microphone).
With Shift+Cursor, the textbox remembers the direction of the selection even after you release the Shift key, but when you look at the properties of the textbox you always get the same information, regardless of whether you selected the right margin and used Shift+Left or if you selected the left margin and used Shift+Right. So what am I supposed to do when the corresponding button is pressed: Decrement SelectionStart or decrement SelectionLength ?
Perhaps I could send the corresponding keys to the TextBox (I want to select words, so Shift+Ctrl+Left/Right could work), but that seems like a hack to me and I'd rather avoid it...
And what if I want to select sentences, not only characters or words?
Hmmm.....
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
I see what you mean... perhaps hold an internal variable that remembers if the selection was right-to-left or left-to-right (a bool would do). Then do an if/else on it.
Left selected:
if (rightToLeft)
{
textBox1.SelectionStart--;
textBox1.SelectionLength++;
}
else
{
textBox1.SelectionLength--;
}
Right selected
if (rightToLeft)
{
textBox1.SelectionStart++;
textBox1.SelectionLength--;
}
else
{
textBox1.SelectionLength++;
}
|
|
|
|