|
I've not noticed it to be slow on any machines.
Anyway, my main focus in these posts is figure out why it doesnt run on some machines.
Does everything seem to work on your machine?
I need to be sure it tuns on others machines.
Thanks a bunch,
Green
www.GreenProductionss.com/C_samples.html
|
|
|
|
|
I have two DataGridViewComboBoxColumns in a DataGridView. Column 1 contains {"A", "B", "C"}. The contents of column 2 should depend on the value displayed in the Column 1 cell in the active row; if "A" is displayed, Column 2 should contain {"1", "2", "3"}; if "B" is displayed, it should contain {"4", "5", "6"}; if "C" is displayed, it should be {"7", "8", "9"}. The change in display should be immediate; i.e., when "A" is selected, Column 2 should immediately display "1" - I shouldn't have to click on another cell to cause the change. How can I do this?
Basicly when I make a selection in one combobox (i.e the one in row 1) then I want the corresponding combobox in row 2 (same row) to update its content immediately. At the moment the update of content only happens once I click somewhere else in the datagridview.
any suggestions
|
|
|
|
|
I've got a bit of brain freeze going on...
I've got an array of control locations (a result of a layout process), and the bounding rectangle is something like -2000, -4000, 2000, 4000...I need to translate these locations so that they can be drawn on a panel control. I don't need them to 'fit' in the panel, i.e. scroll bars are acceptable.
Ideas???
|
|
|
|
|
I'm not sure I understood the question correctly. If you have a control you can add it to your panel and set the Location property to 0,0 (in Forms), that should set that control to the upper left corner. You can calculate the following control's Location with the Height and Width properties of the previous control.
Is this what you want?
V.
|
|
|
|
|
ah no, I've got a set of locations but if I were to directly add them to the panel they would be outside the bounds, clientbounds I think.
The locations were set it via in a unrelated coord space, I need to translate these cords so that they will be visible on the panels left/top 0,0 coord space.
I don't think it's a simple PointToClient/PointToScreen type thing...or at least I couldn't get that to work.
I think I need to use Point.Offset, but its working out the offset values that I'm struggling with.
Or maybe there's an alternative, can I change the panel's bounds? So that its the same as the bounds of these locations?
So my controls are in a rectangle (-x, -y, w, h), and I thought if I just move each location by +x1,+y1 then that should mean they would be visible on the panel which would be (0,0,pw,ph)
does that make any sense???
|
|
|
|
|
Do you have relevant code (not too much please) I'm not quite following what' happening.
- Which property is set out of bounds? How did you get that value (-3000 eg)
- Are you using Forms or WPF?
- What exactly did you try already?
V.
|
|
|
|
|
mmm, that might be difficult (and confuse things)...but I'll give it a go.
I've got an array of controls NodeLayout which are moved about by a Force-Based Graph Layout algorithim, which starts of setting the locations to a random value (-50,50), then shifting them about as it iterates. I've also got the following function:
private Rectangle GetDiagramBounds()
{
int minX = Int32.MaxValue, minY = Int32.MaxValue;
int maxX = Int32.MinValue, maxY = Int32.MinValue;
foreach (NodeUI node in GraphUI.NodeUIs)
{
if (node.Location.X < minX)
minX = node.Location.X;
if (node.Location.X > maxX)
maxX = node.Location.X;
if (node.Location.Y < minY)
minY = node.Location.Y;
if (node.Location.Y > maxY)
maxY = node.Location.Y;
}
return Rectangle.FromLTRB(minX, minY, maxX, maxY);
}
Which returns the bounds of the resultant locations.
When this routine runs, that GetDiagramBounds returns values like (-2000, -6000, 3000, 5000).
I would like to draw these controls on a panel (although if that's the wrong control then I'm happy to change). But when I do, nothing appears, I'm thinking because the panel has a drawable area, and I'm drawing outside that area.
So I need to shift/translate all the positions so that they appear within the panel, but without altering their relative positions. I thought that meant shifiting so their location is > 0,0...
So at the moment I've got as the final step for each control in the array (nodeUI is the control):
Point newLoc = nodeUI.Location;
newLoc.X += Math.Abs(logicalBounds.X);
newLoc.Y += Math.Abs(logicalBounds.Y);
nodeUI.Location = newLoc;
logicalBounds being the result of that GetDiagramBounds function above.
But the locations are still < 0,0 for most of them.
|
|
|
|
|
mmm, It looks to me like you need to calculate or determine your offset and change the location of the elements with that offset.
I would do the following.
1. Add a control to the panel via code and set it to an offset 0,0, then 10, 10 then -10, 10.
2. Try to hardcode 1 element to an offset on your screen, if it shows, you have your problem
3. Add a button that adds/substracts an offset (eg 100) and make your panel update accordingly.
- What kind of control is the NodeUI? is it a viewable control? (what happens if you hardcode one on a panel?
- You did use mypanel.Controls.Add(whatevercontrol) ?
- Did you try to redraw the panel with the update or invalidate method (can't remember which one)
- You could create a panel in code which is big enough to hold all controls, add the controls to this panel and add that panel to the panel you need, that should definitely show the scrollbar. (change the background to something obvious so you're sure it's added)
V.
|
|
|
|
|
NodeUI is viewable, and they all start visible on the panel, and they are added via Control.Add.
I do use Invalidate() to redraw (also to draw the lines connecting NodeUI's, these aren't controls and I just paint on the panel directly)
For certain array's of nodeui's everthing works, and all the controls are visible...but I think that's more by fluke rather than logic!
Using the create new panel idea seems a good approach...I'll give that a go.
Thanks for your help and ideas.
|
|
|
|
|
ne more thing, now I think about it. Make sure you use suspendlayout/resumelayout correctly.
good luck.
V.
|
|
|
|
|
I think its working with this (I forgot to grab the exact same data I was having problems with)
List<NodeUI> newNodeUIs = new List<NodeUI>(NodeUIs.Capacity);
int minX = (nodeLayouts.Min(l => l.Location.X) * -1) + 50;
int minY = (nodeLayouts.Min(l => l.Location.Y) * -1) + 50;
for (int i = 0; i < this.NodeUIs.Count; i++)
{
NodeUI nodeUI = FindNodeUI(nodeLayouts[i].Node);
Point loc = nodeLayouts[i].Location;
loc.X += minX;
loc.Y += minY;
nodeUI.Location = loc;
newNodeUIs.Add(nodeUI);
}
panelGraph.Controls.Clear();
panelGraph.Controls.AddRange(newNodeUIs.ToArray());
panelGraph.ClientSize = GetNodeLayoutBounds(nodeLayouts).Size;
NodeLayouts is not the array of controls, but a struct with their original positions in, the layout algorithm works on that instead. But I think it was using the min of the locations rather than the bounds to do the offset that worked.
Thanks again for your help!
|
|
|
|
|
You're welcome, and also thanks for the feedback. It's nice to know you found a solution.
V.
|
|
|
|
|
I was reading this thread with interest; glad you have an answer.
It's interesting that if you turn the Auto-Scroll of a Form on, and place some controls way beyond the nominal size:
private void Form1_Load(object sender, EventArgs e)
{
button1.Left = 6000;
button2.Left = 9100;
}
and then inspect the DisplayRectangle of the Form you can see negative co-ordinates like:
{X=-7891,Y=0,Width=9175,Height=733}
In the DisplayRectangle bounds.
Makes me wonder if there might be some way to exploit/map DisplayRectangle.Bounds to create a simpler means of translation of Control positions mapped to a different co-ordinate scheme.
By the way, if you have time, I'd appreciate your response to a question I have posted in the 'Algorithms' Forum[^]
best, Bill
"In the River of Delights, Panic has not failed me." Jorge Luis Borges
|
|
|
|
|
Where is here something for beginners to learn?! Thanks
|
|
|
|
|
Qlex wrote: to learn?!
Learn what?!
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
Use the menu bar at the top of the screen, or start here[^].
Unrequited desire is character building.
|
|
|
|
|
C#, WPF...
I've been for some time on this site, but everything seem quite for advanced users.
|
|
|
|
|
There are lots of beginners articles just select the Beginner Articles section from the Articles menu, and add C# WPF to the filter. You need to get used to using search tools in order to find what you are looking for.
Unrequited desire is character building.
|
|
|
|
|
I've looked there, but doesn't seem beginner level. I'll try again!
|
|
|
|
|
If you cannot find anything that you consider "beginner" level, then I think you need to start with some introduction type books, as it would seem you are still at a very early stage of learning. Articles on this site tend to assume that you know the basics of the language you are interested in.
Unrequited desire is character building.
|
|
|
|
|
Seeing the thread I'd recommend a book first.
Internet is difficult if you're starting from scratch. I would recommend a good book and come here when you have an exercise that isn't going as you expect. Once you've got the hang of it, the articles will make more sense.
Hope this helps.
V.
|
|
|
|
|
Yes. Good answer, and recommendation.
|
|
|
|
|
|
Start here[^]
Bastard Programmer from Hell
|
|
|
|
|
Yeah, Eddy, from Kids corner :P
|
|
|
|
|