|
THat's what these[^] folks have done, so you might want to take a look.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Try MS's WebBrowser control. There are a couple of good articles here on CP about using it.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
I have a form which is supposed to display data from a database. The form has many controls which are bound to various fields in the database. Now among the controls I have some comboboxes. The role of these comboboxes is supposed to be to limit the entries the user can make to a small set of values. Now, I want to be clear here, I am NOT using the database to populate a combobox as in about 95% of all examples I've found do. Okay, so I tried this:
MyComboBox.DataBindings.Add(new Binding("Text",MyDataView,"MyField");<br />
This will display the correct string from the database in the combobox, but any changes don't get passed back to the datasource.
So, I tried this:
MyComboBox.DataBindings.Add(new Binding("SelectedItem",MyDataView,"MyField");<br />
The problem here is that the very act of binding the data seems to trick the dataset into thinking that that row has been changed - It's RowState gets changed to modified whether anything has been done to or not.
So, at this point I was getting frustrated and desperate. I decided that what I should do is create a new ComboBox class that inherits from the original class and add an extra property that I could bind to. That way I could keep control of it, right? Wrong! Doesn't work. I even tried this:
public class DataComboBox : ComboBox
{
private string bound;
public string Bound
{
get { return bound; }
set
{
if (value != bound)
{
bound = value;
}
}
}
}
And this:
MyComboBox.DataBindings.Add(new Binding("Bound",MyDataView,"MyField");<br />
Note that this doesn't even change the combobox at all at this point, and even this causes the dataset to think that the row has been changed! How can this be??? I'm totally stumped.
Anybody got any ideas?
Cheers
|
|
|
|
|
I cant remember the method, but its called EndCurrentEdit() in the binding manager. Just call that
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Thanks for the reply, but can you elaborate on exactly when and where I need to do this? I tried calling it at the end of the set method of my property, but that didn't seem to do anything at all. I also tried adding it to the PositionChanged event of my binding manager, but that didn't do anything either
|
|
|
|
|
First of all, I'm kind of a n00b on C# (only been at it for 3 months on and of now..) I'm trying to bind a DataGrid to a collection (that is strongly typed, has IBindingList etc. implemented), but I don't want all fields shown (like Id, InsertTime, updateTime etc.)
I've 'been looking all over the internet but can't find anything about the subject, everything I find is about DataTable/DataSets, or about ASP.NET, where the DataGrid has an AutoGenerateColumns boolean that you can set to false.
Does anyone here have an example I could look at?
|
|
|
|
|
Create you own DataGridTableStyle and map it to your datasource. Then create GridColumnStyles for each field you want to display, and add them to your DataGridTableStyle. Finally add the DataGridTableStyle to your DataGrid. If you get the mapping right (which can be a little tricky!) it should display your TableStyle and only the columns you added to the TableStyle.
|
|
|
|
|
Just found it out myself . If you create the GridStyle, you have to set it's mappingname to the type of your Collection, so if your collection is of Type CompanyCollection, that should be the mappingname.
Tricky indeed...
|
|
|
|
|
partyganger wrote:
Tricky indeed...
What I meant is that (IMHO) it doesn't parallel what you do with a dataset. In a dataset you give it the name of the table, so (again IMHO) with a collection you might expect to give it the name of that instance of the collection or maybe the name of a property in your class (if you class wrapped a collection), but you don't, you give it the name of the type of the collection (as you rightly pointed out). That seem counter-intuitive to me and it also means that you can't switch a datagrid from binding one collection object to another collection object of the same type and expect it to automatically switch styles (because they'd both use the same mapping).
Sheez...sorry I bothered
|
|
|
|
|
Hi!
I have really weird break point. Look at my screen shoot
http://www.mapsea.com/vs.jpg
First break is normal and can stop when program run to that position.
Second break show with a question symbol inside. move the mouse cursor over it. It say the break won't be hit for no runnable code associated with it. But I can stop at the first position and get to the second one by trace step by step. In fact, the lines below that has the same bad behaviour, the lines above it act as normal break.
I really don't know what's wrong. Is it a bug of Visual Studio or a my own fault? It happens in several files in my workspace. I can't bear it any longer. I have rebuild the project several times, but with same result. Anyone know the solution to get rid of it?
Thanks!!
|
|
|
|
|
I had a similar problem when I had an assembly with the same version number in the GAC as the one I was building. Removing the file from GAC was the solution.
HTH
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Thanks for your response.
But I still don't know what to do. I didn't modify any assembly's version manually yet. And don't know which one conflict.
Can you describe some more detail for me?
Thank you!!
|
|
|
|
|
Hi novachen,
I dont know why this is happening, but to explicitly break at some point, instead of using a breakpoint, try using System.Diagnostics.Debugger.Break();
Do let me know if it helps..
Cheers,
Rahul
I do not understand what I do. For what I want to do I do not do, but what I hate I do. - Romans 7:15
|
|
|
|
|
Hi,
Is there any way I can make panel corners rouhd, whithout using any kind of image?
Thanks
|
|
|
|
|
Derive from Panel and override OnPaint using various methods from the Graphics object that is passed to you in the PaintEventArgs . Depending on how you do it (and how much you want to paint), you may need to set various control styles in your constructor. See Control.SetStyle and ControlStyles for information about what each style is used for.
Specifically, see Graphics.DrawArc .
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
|
I found it does not work when I wrote a mybutton inherited from Button class and use mybutton.Click += new System.EventHandler(functionname), and nothing respond.
So who can tell me how to deal with it.
|
|
|
|
|
chq12 wrote:
So who can tell me how to deal with it.
See the reply below!
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
|
Did you override any ControlStyles with Control.SetStyle ? If not, you overwrote some other functionality and caused the button control to not get notification of click events. What else did you do to it?
And, yes, everything inherited is still callable from derivitive classes unless overridden or hidden (through the new modifier for non-virtual methods / properties). That why you should look to see what else you did the derivitive button class. For instance, if you used SetStyle(ControlStyles.Selectable, false) , the click even shouldn't fire anymore. Overridding WndProc is especially dangerous if you don't forward non-handled messages back to the base (with base.WndProc ).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I override some method, such as OnMouseUp, OnMouseLeave, OnMouseEnter and OnMouseDown, following is the code. Someone told me I should call base method, But how can i call it? or it is from other problem.
myButton testbutton = new myButton("test", new Rectangle(0,0, 45, 45));
this.testbutton.Click += new System.EventHandler(testbutton_click);
class myButton : System.Windows.Forms.Button{
int ShowType;
Brush backBrush;
Brush textBrush;
Font myFont;
public myButton(String title, Rectangle rect){
backBrush = System.Drawing.Brushes.Violet;
textBrush = System.Drawing.Brushes.Green;
myFont = new Font(FontFamily.GenericSerif, 18, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Pixel);
this.Bounds = rect;
this.Text = title;
GraphicsPath myPath = new GraphicsPath();
Rectangle rect1 = new Rectangle(0, 0, this.Bounds.Width, this.Bounds.Height);
myPath.StartFigure();
myPath.AddArc(rect1, 0, 360);
myPath.CloseFigure();
this.Region = new Region(myPath);
ShowType = 0;
}
protected override void OnMouseEnter(EventArgs e){
backBrush = System.Drawing.Brushes.Orange;
textBrush = System.Drawing.Brushes.Green;
ShowType = 0;
Invalidate();
}
protected override void OnMouseLeave(EventArgs e){
backBrush = System.Drawing.Brushes.Violet;
textBrush = System.Drawing.Brushes.Blue;
ShowType = 0;
Invalidate();
}
protected override void OnMouseDown(MouseEventArgs e){
backBrush = System.Drawing.Brushes.Orange;
textBrush = System.Drawing.Brushes.Blue;
ShowType = 1;
Invalidate();
}
protected override void OnMouseUp(MouseEventArgs e){
backBrush = System.Drawing.Brushes.Orange;
textBrush = System.Drawing.Brushes.Red;
ShowType = 0;
Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
SizeF mySizeF = e.Graphics.MeasureString(this.Text, myFont);
e.Graphics.FillRectangle(backBrush, new Rectangle(0, 0, this.Width, this.Height));
if(ShowType==1)
e.Graphics.DrawEllipse(System.Drawing.Pens.Red, new Rectangle(0, 0, this.Width, this.Height));
int offwidth = (int) ((this.Width - mySizeF.Width)/2);
int offheight = (int) ((this.Height-mySizeF.Height)/2);
e.Graphics.DrawString(this.Text, myFont, textBrush, offwidth, offheight);
}
}
|
|
|
|
|
If you're overriding those and not calling the base class's implementation, there's your problem. Unless you have a VERY good reason to not call the base class (such as handling EVERYTHING in your override), always call the base class's implementation, either before or after your code (depending on what's important, but usually doesn't matter).
To do so, just use the base reference:
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
} . See? Not hard at all.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
yes, it worked, thanks very much
|
|
|
|
|
Hi,
I have searched here and google but cannot find what I am looking for. I have a status bar,richtextbox and menu control in my application. The rtb is set to fill the form, which docks it between the bottom of the form and the bottom of the menu. When the status bar is active it appears at the bottom of the form.
Now my problem is when the status bar is active(visable) it goes over my rtb covering up a the hscrollbar. I am wondering if there is anyway i can get the rtb to dock to the top of the status bar like it does to the bottom of the menu.
Thanks alot in advance.
ps. if anyone is wondering its a notepad clone, so i can gain skill with C#.
|
|
|
|
|
Try right clicking on the object that is covering up your object and click "Send to Back". It sounds like a simple layering issue.
|
|
|
|
|