|
I just compiled it for .NET 1.1 and my code works fine. You could try reinstalling .NET but remember that this control and many others encapsulate their Windows Common Control equivalents. Make sure you have all the latest services packs and updates first. I've followed the calls and .NET doesn't really care too much about the value of ColumnHeader.Width - it passes it to the header control for the List-View common control using SendMessage - practically unscaithed.
-----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've comiled your code and ran in on three machines 2 WinXP and 1 WinServer 2003, all with up2date service packs and none of them worked.....I just don't get it. Text is present, width is just zero....WTF is right.
|
|
|
|
|
I'm a pretty new programmer. I'm using C#. I'm writing a program that reads and writes data to and from an MS Access database. I have the database set up so I cannot write null values to it. When I try to do so I get an error message. I understand that the database cannot accept null values but I want the user to be able to understand this as well, I want to write a custom error message. Can someone tell me how this is done or tell me where to look for more info on this topic.
thanks
|
|
|
|
|
Create a custom form that dispalys the message. In the catch block (if you are using try-catch) just show the form!
|
|
|
|
|
Or,put all the code for database in try/catch and get OleDbException ,and check the Message or ErrorCode property and if it is that error,show an user friendly in MessageBox .
Mazy
No sig. available now.
|
|
|
|
|
a user friendly
/\ |_ E X E GG
|
|
|
|
|
Please read on and help me!
When you create a custom component and inherit (standard) from System.Windows.forms.Usercontrol, VS.NET shows a nice workarea in Design where you can place all kinds of winform controls like a textbox, button, etc.
But when I try to inherit from Panel, the area in Design disappears and is replaced by screen which says "to add components to your class.... click here to switch to code view"
I can't use this to make custom panels!
What I'm trying to do is the following:
I want a winform app (like Outlook) and everytime the user chooses a menuitem,I want to load the corresponding panel. I don't want to load all the panels at once, this will take to much time and memory.
So that's why I want to inherit from Panel, add the needed controls and then load the panel at runtime when needed.
Please, if you can help, mail me!
Or if you think I should tackle this another way, tell me so!
Thanks!
Ernst Wolthaus
|
|
|
|
|
When you inherit from Panel,if you want to add controls just double click on a controls on toolbox and they added to your form,then you should manully set the positions , size and other properties in code-behind. Whats your problem with it?
Mazy
No sig. available now.
|
|
|
|
|
When you inherit from Panel, you lose the design view in VS.NET. That was my problem.
And when I lose the design view, I can't just add controls visually because it just doesn't work right anymore.
But fortunately Jose gave me the solution, by added some attributes to the custom control.
Thanks anyway!
|
|
|
|
|
If you can't use the designer, just code the controls manually.
As far as displaying custom panels (or any scrollable control, for that matter), derive your custom panel Types (classes) and store the Type of the derivative panels as properties of the item on which the action occurs, such as clicking on a menu item. Since you're dealing with MenuItem s, also extend MenuItem with your own class and add a property, kind of like:
public class MyMenuItem : MenuItem
{
private Type panelType;
public MyMenuItem() : this(null, null) {}
public MyMenuItem(string text) : this(text, null) {}
public MyMenuItem(string text, Type panelType) : base(text)
{
this.panelType = panelType;
}
public Type PanelType
{
get { return this.panelType; }
set { this.panelType = value; }
}
} Treat this menus like normal, adding them to a MenuItems collection just like normal. When a user clicks on the MenuItem , you will use that Type as you'll see shortly. For brevity, assume that each MenuItem uses the same Click event handler:
private void menu_Click(object sender, EventArgs e)
{
MyMenuItem menu = sender as MyMenuItem;
if (menu != null)
{
if (menu.PanelType != null)
{
Panel p = Activator.CreateInstance(menu.PanelType) as Panel;
if (p != null)
{
p.Dock = DockStyle.Fill;
leftContainer.Controls.RemoveAt(0);
leftContainer.Controls.Add(p);
}
}
}
} This is just a very basic example but I hope you get the idea. Creating instances of unknown Types (or from a collection of Types, perhaps configured in a .config file) is fairly common. I do this A LOT in our enterprise app I designed. It goes much deeper than this, but this is the essential idea.
-----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-----
|
|
|
|
|
You can create a new class A inheriting from Panel adding the next lines of code. After that all the classes inheriting from A will have again the design view.
<br />
[Designer(typeof(System.Windows.Forms.Design.DocumentDesigner),typeof(System.ComponentModel.Design.IRootDesigner))]<br />
public class A : System.Windows.Forms.Panel<br />
{<br />
....<br />
}<br />
...<br />
public yourpanel : A<br />
{<br />
....<br />
}<br />
|
|
|
|
|
Thanks to all responses to my questions!
Jose Fco Bonnin gave me just what I needed! After making my own custom panel type I inherited from that to create a panel I'm going to use in a winform app and it did show the design view again, great!
|
|
|
|
|
I have listbox that view data where the order of this data is important, so i need to add two buttons, to allow the user to change the item index in the listbox
the first button will decrease the index by 1 (up)
and the other will increase it by 1 (Down)
and i do know how to change the index number
thnx in advance
|
|
|
|
|
Thank u
I did it my self
and here is the code
private void btn_up_Click(object sender, System.EventArgs e)
{
if(this.lb_target.SelectedIndex != -1)
{
if (this.lb_target.SelectedIndex != 0)
{
object tempob=this.lb_target.SelectedItem;
int index=this.lb_target.SelectedIndex;
this.lb_target.Items.Remove(this.lb_target.SelectedItem);
this.lb_target.Items.Insert(index-1,tempob);
this.lb_target.SelectedIndex=index-1;
}
}
}
private void btn_down_Click(object sender, System.EventArgs e)
{
if(this.lb_target.SelectedIndex < this.lb_target.Items.Count-1)
{
object tempob=this.lb_target.SelectedItem;
int index=this.lb_target.SelectedIndex;
this.lb_target.Items.Remove(this.lb_target.SelectedItem);
this.lb_target.Items.Insert(index+1,tempob);
this.lb_target.SelectedIndex=index+1;
}
}
|
|
|
|
|
i wanna to know the tool or the class that we can use in c# that we can make fullscreen game animation as that in the openGL
tona
|
|
|
|
|
You have to have DirextX9.0 SDK. And when you install it there are some samples with it which you canfind your answer there.
Mazy
No sig. available now.
|
|
|
|
|
or just use CsGL(OpenGL Port to C#)
csgl.sf.net
scio me nihil scire
My OpenSource(zlib/libpng License) Engine:
http://sourceforge.net/projects/rendertech
Its incurable, its a Pentium division failure.
|
|
|
|
|
Dear, Sir
I launch Calculator by the following code
System.Diagnostics.Process.Start("calc.exe");
How to active the Calculator I have launch again when I press a button on my App.
Thank You.
Sorry for bad English.
|
|
|
|
|
I think what you want is to activate the calculator app. you have already launched through code, without launching another instance of it.
For this you need to use FindWindow api to determine whether you have the application(calc) active and then activate it by SetFocus API.
You need to pass the handle returned by FindWindow function to the SetFocus API. You need to P/Invoke for calling these two API's.
Cheers,
Kannan
|
|
|
|
|
I'm really frustrated with this. The images looks fine under edit mode, but they all disappeared when the application is running. What happened?
I know there is a solution about adding "Application.DoEvents()" after "Application.EnableVisualStyles()", but it doesn't work for me...
Anyone has an explanation? Thanks!
|
|
|
|
|
Does it work if you dont call Application.EnableVisualStyles()?
I have stopped using that, and just put a manifest file together with my app, much less problems...
- Anders
Money talks, but all mine ever says is "Goodbye!"
My Photos[^]
|
|
|
|
|
I have tried all, with or without EnableVisualStyles(), with or without manifest file. Nothing works.
It actually worked for me for a while, but at some point during coding(probably after I changed the font to some labels on the toolbar), it disappeared and would never get back.
Anders Molin wrote:
Does it work if you dont call Application.EnableVisualStyles()?
I have stopped using that, and just put a manifest file together with my app, much less problems...
|
|
|
|
|
|
After a research using Diff tools, I found the problem was the font of the tool bar. It worked fine under default font, but if I change it to any other font, even after I changed it back to the original default font, the images on toolbar will disappear!!!
I don't know why, it's probably a bug of Microsoft.
I wrote a small Windows Form app, it works fine. It's only in my application that the font change will affect the toolbar images.
Thanks,
Jason
|
|
|
|
|
Hi,
In VC++ 6, I can put "\t" in the text of a static control and it will show as a tab. But in VC# .Net, it doesn't work for me? How can I insert a tab?
Thanks!
|
|
|
|