|
You can get row count for instance as:
1. If DataSource is a DataTable
((DataTable)myGrid.DataSource).Rows.Count
2. If DataSource is a DataSet
((DataSet)myGrid.DataSource).Tables[myGrid.DataMember].Rows.Count
etc. with DataView. Next problem - DataGrid can have some sources (like DataSet). You must specify, what DataTable rows You want to count.
Next solution it is to use protected DataGrid property ListManager in inherited object:
((DataView)this.ListManager.List).Count
Hi,
AW
|
|
|
|
|
Thanx
sorry for my bad English.
|
|
|
|
|
Does anyone know if I can formatonly part of the TextBox.Text property.For Example if I assign Textbox.Text = "Hello World"; , is it possible to make word "Hello" red and "world" blue?
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
As far as I know, not unless you impliment the text property yourself in a subclassed control.
You might want to try using an RTF control.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
Override Paint() ore something like this in class inherited from TextBox I think
Hi,
AW
|
|
|
|
|
How I can receive emails from SMTP server using Outlook object ? (Outlook XP v10)
|
|
|
|
|
have you gone thru GDN
www.gotdotnet.com site.
you can get excellent samples there. !!!
here is the smtp sample for you !!!
http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=958BAB96-82EF-4ACD-8F16-8725A2DEA946
Paresh
|
|
|
|
|
Using C# in a winform, I'm creating a file backup program that uses a treeview/listview pair, just like Windows Explorer, only exception is that all entries have checkboxes for selection... you make your selections and then save a backup file (in XML) containing a record of all dirs/files for that job. Works fine.
In order to edit a saved job, the treeview/listview pair must be "re-hydrated", so that all selections for a given job are restored and the user can view and make changes.
I know you can programmatically check/uncheck items, but I'd like to make the selections by sending mouse click messages, just as if I were making the selections for the first time with a mouse... can't use the "node.Check = true" method because it conflicts with my job creation logic.
Is it possible to send mouse click messages programmatically...??? How is it done...?
thanks very much.
|
|
|
|
|
you can Invoke the tree's onmouseclick event with that when you fill the tree event object fill the node you want so as if it clicks on that item.
Paresh;)
|
|
|
|
|
thanks for the reply... can you give me more info or an example of how I can send a mouseclick message to the treeview entry...???
thanks...
|
|
|
|
|
Ok Here is the code what I tried !!!
you can compile and run under shell by
> csc Form1.cs
> Form1
you can derive the TreeView Class and make protected method callable via making public and calling protected method.
Hope this helps or gives hints to your stuff !!!
----------------------------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WinTreeHandle
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private WinTreeHandle.Form1.MyTree treeView1;
class MyTree : TreeView
{
public void OnMyAfterCheck(TreeViewEventArgs e)
{
e.Node.Checked = true;
this.OnAfterCheck(e);
}
}
private System.Windows.Forms.Button buttonClick;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
bool bLoading = true;
public Form1()
{
bLoading = true;
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
bLoading = false;
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.treeView1 = new WinTreeHandle.Form1.MyTree();
this.buttonClick = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// treeView1
//
this.treeView1.CheckBoxes = true;
this.treeView1.ImageIndex = -1;
this.treeView1.Location = new System.Drawing.Point(16, 24);
this.treeView1.Name = "treeView1";
this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node0"),
new System.Windows.Forms.TreeNode("Node1"),
new System.Windows.Forms.TreeNode("Node2"),
new System.Windows.Forms.TreeNode("Node3"),
new System.Windows.Forms.TreeNode("Node4")});
this.treeView1.SelectedImageIndex = -1;
this.treeView1.Size = new System.Drawing.Size(208, 144);
this.treeView1.TabIndex = 0;
this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterCheck);
this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
//
// buttonClick
//
this.buttonClick.Location = new System.Drawing.Point(240, 32);
this.buttonClick.Name = "buttonClick";
this.buttonClick.Size = new System.Drawing.Size(96, 40);
this.buttonClick.TabIndex = 1;
this.buttonClick.Text = "Click To Raise Event";
this.buttonClick.Click += new System.EventHandler(this.buttonClick_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(344, 221);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.buttonClick,
this.treeView1});
this.Name = "Form1";
this.Text = "Tree Handling";
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void buttonClick_Click(object sender, System.EventArgs e)
{
TreeViewEventArgs e1 = new TreeViewEventArgs(treeView1.Nodes[0],TreeViewAction.ByMouse);
treeView1.OnMyAfterCheck(e1);
}
private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
if ( bLoading ) return;
MessageBox.Show(e.Node.Text);
}
private void treeView1_AfterCheck(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
if ( bLoading ) return;
MessageBox.Show(e.Node.Text);
}
}
}
-Paresh
|
|
|
|
|
Please check this code first:
Console.Write("{0}-{0}","2");
I want it to write "2-{0}" not "2-2". How can I do this?
|
|
|
|
|
I don't know how to escape {0} , but there's another way to do what you need:
string value = "2";
Console.Write(value + "-{0}");
Regards,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
try \{
that's the escape sequence char.
|
|
|
|
|
pareshgheewala wrote:
try \{
that's the escape sequence char.
Well, that doesn't work too, I don't really know the escape character for this but you could use the following workaround
Console.Write("{0}-{1}", 2, "{0}");
that will result:
2-{0}
(a.k.a. Wal2k) www.wal2k.com
|
|
|
|
|
hey I found it, just use {{ and }}
Console.Write("{0}-{{0}}",2);
(a.k.a. Wal2k) www.wal2k.com
|
|
|
|
|
Hi:
I'm working on a custom control that inherits System.Windows.Forms.Control. What I need the PropertyGrid control do is to hide most of the inherited properties of my custom control. There is a property BrowsableAttributes that is probably meant to do the job but I don't have the slightest idea how this is done! Is it possible for the PropertyGrid to show only the properties I specify?
10x,
Kaloyan
|
|
|
|
|
Using the attribute "[Browsable(false)]" should do the trick.
As an example ...
[Browsable(false)]
public string MyStringProp
{
get {....}
set {....}
}
would prevent the property grid from displaying the properity. Setting it to true then would allow the grid to display the properity.
Hey don't worry, I can handle it. I took something. I can see things no one else can see. Why are you dressed like that?
- Jack Burton
|
|
|
|
|
This, however, does not solve my situation... My control inherits around 30 properties from Control which I do not need. So the problem is that I want the PropertyGrid to display only those few that are specific to my control but not inherited from Control. If I use the approach you propose I'll have to add the Browsable(false) attribute to all inherited properties. And this takes a lot of time. The PropertyGrid, however, has that property: PropertyGrid.BrowsableAttributes (the last letter is the difference), which is meant to enable the grid to display only those prperties you want to display. That is what I'm asking and trying to solve in the same time.
Thanks for the response anyway...
Kaloyan
p.s. I fixed this one It turned out that PropertyGrid.BrowsableAttributes must be set to the attributes the properties I want to display have.(confusing, isn't it? )
|
|
|
|
|
I'd like to access the members of an event, such as the KeyDown event of a TextBox. Here's an example:
int handlerCount = textBox.KeyDown.GetInvocationList().Length;
This would tell me how many handlers are attached to this event. But the compiler doesn't like it, and gives me this error:
CS0079: The event 'System.Windows.Forms.Control.KeyDown' can only appear on the left hand side of += or -=
What's going on? How can I accomplish what I need?
Thanks,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
Alvaro Mendez wrote:
What's going on? How can I accomplish what I need?
I had the same need and just couldnt get a solution...
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
check Control's event property
for example
this.Events
and it has a AddHandler and getting active handlers ..
Paresh
|
|
|
|
|
I am getting the following exception:
"System.ExecutionEngineException In System.Windows.Forms.Dll"
... and it is occuring when the code is just about to exit the Static void Main block:
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new Form1());<br />
}
Has anyone any idea of what could be causing this?
Cheers
|
|
|
|
|
I would check the destructor of Form1 or one of its object's dtors. A stack trace would be of great help.
|
|
|
|
|
do you have some kind of Active X or image you are using ?
try to trace the constructor
put a break point in Form1's ctor and try debuging from there
u will be doing F11 not the F10 which skips method debuging.
and step by step you will know exact where it fails.
Paresh;)
|
|
|
|