so much for the simple answer... I'm reminded of a similar problem I once had with a RichTextBox, where I needed to force it to redraw its scroll-bars. I solved that problem by writing a method along the lines of the following: (C# code, sorry) private void Jiggle() { if (this.Orientation == Orientation.Horizontal) { this.rtfBox.Width -= 3; this.rtfBox.Width += 3; } else { this.rtfBox.Height -= 3; this.rtfBox.Height += 3; } this.rtfBox.Invalidate(); } I then called this method from the method that needed to redraw the RichTextBox (which was a property setter for a container control). I was surprised how well it worked. Especially since the RichTextBox in question had its Dock property set to DockStyle.Fill. I'd suggest dynamically changing, by a small number of pixels (fewer than 8), the Width of one of the ColumnHeaders in your DataGridView, since it works when you click it. Or to change the Sort column to a different column, then back to the original column. HTH Sebrell -- modified at 14:30 Wednesday 18th October, 2006
Sebrell
Posts
-
Datagridview not refreshing -
Datagridview not refreshingHave you tried calling Control.Invalidate(), then calling Control.Update() ? The sequence of these two method calls should force the DataGridView to redraw itself.
-
g.DrawString to display floating point?You must specify the format by calling the System.Single.ToString(string format) overload.
Standard numeric formats are listed on MSDN at Standard Numeric Format Strings.
Custom numeric formatting is discussed at Custom Numeric Format Strings. -
WinForms: programatically created control will not paintA thought: does your code call the Invalidate() method of the parent control? This method has multiple overloads, three of which take a boolean parameter "invalidateChildren".
-
Custom toolbar control in .Net frameworkThis will be available with Whidbey, but there are also a couple examples here at CP for v1.1.
-
DpiYou can indeed set drawing units as inches (System.Drawing.GraphicsUnit.Point is 1/72 inch). Plus, you can get the DPI values from the System.Drawing.Graphics.DpiX and DpiY properties.
-
XmlNodes in a ListBox and junk...This is not a simple solution like the above, but it is easy to do in Visual Studio: get the schema for your documents, create a typed DataSet from the schema, use a dataset instance in your form, and set the appropriate table/column for the ListBox.DataSource and ListBox.DataMember properties.
Just a thought.
-
TreeStructure problemyou're very welcome. Also, I realize upon reading your last message why you need to convert the Point. The MouseEventArgs X and Y properties relate to screen co-ordinates. Controls use co-ordinates based on their parent control's ClientRectangle. The conversion forces the TreeView to determine the screen co-ordinates of its own ClientRectangle, which it otherwise has no need to know. I don't suppose you know a fast and reliable way to serialize rich text, do you?:)
-
findControl & checkbox statefor question 1, are you searching for a Control whose Id value you set at design-time? that is, can you use
document.getElementById(knownControlId)
in client-side javascript? for question2, I'd try using<input type="hidden" id="ipt_[associated Image Id]" value="false" />
then use script (I'm big on client-side script) to handle the checkbox onclick event.function checkboxClicked(checkBox){
var sId = checkBox.id;
if (sId){
// use a naming convention to convert to the id of the input
var inputElem = document.getElementById(sId);
if (inputElem && inputElem.value) {
inputElem.value = "true";
}
}
}
Then add
onclick="checkBoxClicked(this);"
for each checkbox. This approach, although it relies on a naming convention, allows you to have access to the information on both server and client side. HTH -
Prevent killing an app through "End task"I'm really curious what you want this for.
-
TreeStructure problemI forgot to add that you might want to change the value of tvAlbums.FullRowSelect and see what effect that has.
-
TreeStructure problemIn that case, a call to tvAlbums.SelectedNode.Bounds.Contains(new Point(e.X, e.Y)) should tell you whether the node was clicked.
-
TreeStructure problemTry checking the tvAlbums.SelectedNode property instead of calling GetNodeAt - does it give you the correct Node reference? whoops -- i mean "in addition to calling GetNodeAt"
-
TreeStructure problemOr, the other way around, you can inherit from TreeView, create its nodes dynamically, and set each node's Tag property with an appropriate nested class instance.
-
TreeStructure problemYou need a reference to the TreeView, and to set a TreeViewEventHandler for its AfterSelect event. TreeViewEventArgs has a Node property that returns the selected TreeNode.
-
Preventing multiple button clicks and process recursionI was about to post this when I read your reply. Decided to go ahead and post anyway. /// message Assuming you've assigned an EventHandler delegate from a private method on the Form to handle the Button's Click event, could you set a private flag, and test its value before launching the Process? Something like the pseudo-code below, so you can ignore the Button.Enabled property? (and so the Button doesn't have to know anything about the Process or the Form?)
private void HandleButtonClick(object sender, EventArgs e){
// at the beginning
if (!this.canLaunch) return;
// set the flag before launch
this.canLaunch = false;
Process targetProcess = new Process();
// set EnableRaisingEvents
targetProcess.EnableRaisingEvents = true;
// assign exit event handler
targetProcess.Exited += new EventHandler(this.TargetEnded);
targetProcess.Start(...);
}
// process.Exited handler
private void TargetEnded (object sender, EventArgs e){
this.canLaunch = true;
}
// if other objects need to know:
public bool LaunchEnabled {
get { return this.canLaunch; }
}
HTH JSF