|
dojohansen wrote: it is *always* writeable
Nope.
And are you planning to write to private fields? I don't recommend that.
dojohansen wrote: At least I believe readonly fields is nothing more than a compile-time check
Try it.
P.S. I just tried it and it worked!
modified on Wednesday, November 4, 2009 9:47 PM
|
|
|
|
|
Hi experts........
how to use towords() function in crystal reports......
Thanks in advance
|
|
|
|
|
Can anyone suggest me how to change the colour of scrollbar of richtextbox/panel/gridview ?
As we change the Windows theme, the colour of scroll bar changes.
I want to depict this behaviour in one of my application, but without changing the windows theme.
Thanks in advance!
|
|
|
|
|
Hi,
I only had a look at DataGridView but suppose it is similar for the other controls. The grid does not expose the scrollbar objects, it only exposes the ScrollBars property which is just an enum to define if you want no scrollbars, horizontal/vertical only, or both.
Hence, there is no API for doing what you want to. You can access the scrollbar via the Controls collection, but be aware that if the implementation details of the DataGridView changes, your code may break.
The absolutely easiest and worst way is to simply index into this collection. I tried this code:
void foo()
{
var g = new DataGridView();
ToString();
}
The second line is just a dummy for me to set a breakpoint so I could have a look in the watch list. Set a breakpoint there, make sure something calls foo(), and run. Then add the watch g.Controls and you'll see that by default the grid contains two controls, the horizontal and the vertical scrollbar. Hence, this code would succeed for such a grid:
g.Controls[0].BackColor = Color.Red;
However, the scrollbar may of course not be the first control of the datagrid in all situations, such as when we've databound it. A more robust solution would be to search a part of the control tree for a given type and use that to find the scrollbar. Then your code would depend only on the grid or whatever control contains it having one and only one sub-control of type HScrollBar (for the horizonal one).
Let's put this general code in a separate class so it can be reused, and call it Util for now (you may want to bundle this method with related functionality and make it into a ControlUtil or WinFormsUtil or whatever).
static public class Util
{
static public T Find<T>(Control container) where T : Control
{
foreach (Control child in container.Controls)
return (child is T ? (T)child : Find<T>(child));
return null;
}
}
Now you can use this to find and access subcontrols not directly exposed by the container. You may also want to add a FindAll method to find all subcontrols of a particular type, or one that searches by using a predicate function so you can select a subcontrol based on it's property values rather than only on type. But you get the idea, hopefully.
Usage: Util.Find<HScrollBar>(dataGridView1).BackColor = Color.Red;
Remember however that this approach is not guaranteed to work if and when you move to a new framework version. The grid does not expose any HScrollBar and is free to replace this with some other implementation in the future, in which case your code would break.
Also, for the Panel or other container controls, this won't be enough if the control contain any other controls that have scrollbars! Find here simply returns the first subcontrol found of the given type, and it searches depth first (i.e. if the first subcontrol is not the given type, search it's subcontrols before continuing to the next sibling). But you can adapt this to search level by level if you want, or restrict it to searching only the direct children of the container (I don't know if a Panel's scrollbars are direct children, but it's likely) or use any other method of your choosing to find the appropriate object. In any case you can use the central idea of gaining access to the subcontrol by finding it in the control subtree - as long as you accept that this logic may not be valid forever and might have to change if the controls do.
|
|
|
|
|
Hi there
How do you bind (in WindowsForms) with a textbox to a datasource property with the type of 'decimal?' (that is, Nullable<decimal>)?
To do a straightforward binding is simple, I got that to work, i.e. when you type a value in the textbox it updates in the datasource properly but when I empty out the textbox, I expect the property to have a value of null but the textbox refuses to loose focus or to have any other event to take place until a valid number is entered.
Did anyone had a similar issue?
Let me know if its not clear enough.
Thanks
- Last Attacker
|
|
|
|
|
i want to control mouse movement and clicking using my own application how can i achieve this
|
|
|
|
|
You can achieve it via windows api by sending messages to controls.
|
|
|
|
|
Thanx
if i need some more help regarding the project how can i contact you
|
|
|
|
|
|
you and your question are dump and useless.....
|
|
|
|
|
See the bit at the top of the page "How to answer a question". Please pay attention to point (3).
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
The question asked by him was : sdfhjshdfh....
For this only i have replied like that.... If that hurts i am really sorry....
|
|
|
|
|
Nah, doesn't hurt - but if we can't be rude to them, we can't be rude to them! (Even when the post has been deleted!)
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hello Friends.
I am developing an application in VS2005 using C# in which i have scanned pages and save them in a multi-page tiff file using leadtools control version 15.0. Now i want to sort that scanned pages. suppose the page that I have scanned first want to place it in middle or any place(index) of my choice. can anyone guide me using a sample code that how i can do this using leadtools or any C# function? Please guide me if there is any built in function of leadtools control that will help me to achieve this functionality or any C# feature that can help me to achieve this functionality.
|
|
|
|
|
Member 4624055 wrote: using leadtools control version 15.0.
Did you ask on the Leadtools forum.
|
|
|
|
|
Yes i have also put this question on leadtools form and there support as well but did not get any answer yet.
|
|
|
|
|
Friends Please help me regard to this problem as i am not getting any possible solution yet.
|
|
|
|
|
Hi
I want to write a regular expression to validate my experience field. This field excepts numeric(year) value and decimal(month) value.
For Ex: 4.3(4 yrs and 3 mnths)
I want to validate my texbox value using regual expression so that year is not more than 12 and month is not more tha 11. I need help as early as possible.
Thanks in advance
Nikks
Inderjeet Kaur
Sr. Software Engg
|
|
|
|
|
i think for this you can use Range expression validator instead of Regular Expression
|
|
|
|
|
HI Experts..
How do you convert a number to a string in Crystal Reports?
Plz do reply soon.. Thanks in Advance.......
|
|
|
|
|
I don't have any experience with Crystal Reports, but do you really have to convert a number to a string? I can see the challange in doing the opposite though...
|
|
|
|
|
|
Hi, I have a xml file with more than 1 GB size. I have to read the xml node value from the xml file. I can load the xml file and then read the value of node, but If I load the file its decrease the performance of the application. Is there any other method by which I can read the node value without loading the xml file ?
Pankaj
|
|
|
|
|
Using XMLReader might be one way.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
hii I am desining a form that has glass effect. Well this code works on vista but i need it on Xp. The i am using gets an error saying that "DllNotFound Exception was unhandled". Well I have copyied all the dll that reqired for glass effect from vista.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.DirectX.AudioVideoPlayback;
using System.Diagnostics;
using System.Drawing.Drawing2D;
namespace welcome_page
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
this.FitGlass();
}
Video video;
private welcome_page.VistaGlassEffect.VistaApi.Margins marg;
private Rectangle topRect = Rectangle.Empty;
private Rectangle botRect = Rectangle.Empty;
private Rectangle lefRect = Rectangle.Empty;
private Rectangle rigRect = Rectangle.Empty;
private void FitGlass()
{
// If DWM is not enabled then get out
if (!this.IsGlassEnabled())
{
return;
}
// Set the Margins to their default values
marg.Top = 600; // extend from the top
marg.Left = 400; // not used in this sample but could be
marg.Right = 200; // not used in this sample but could be
marg.Bottom = 860;// not used in this sample but could be
this.Paint += new PaintEventHandler(this.Form1_Paint);
// call the function that gives us glass,
// passing a reference to our inset Margins
welcome_page.VistaGlassEffect.VistaApi.DwmExtendFrameIntoClientArea(this.Handle, ref marg);
}
private void apply()
{
this.Paint -= new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
this.RecreateHandle(); //needed if changing on the fly
this.FitGlass();
}
private bool IsGlassEnabled()
{
//if (Environment.OSVersion.Version.Major < 6)
//{
// Debug.WriteLine("How about trying this on Vista?");
// return false;
//}
//Check if DWM is enabled
bool isGlassSupported = false;
welcome_page.VistaGlassEffect.VistaApi.DwmIsCompositionEnabled(ref isGlassSupported);
return isGlassSupported;
}
// Alpha-blending Paint after the glass extension
// this seems better than the winforms transparency approach because here we can click on the glass!
private void Form1_Paint(object sender, PaintEventArgs e)
{
// black brush for Alpha transparency
SolidBrush blackBrush = new SolidBrush(Color.Black);
Graphics g = e.Graphics;
if (this.IsGlassEnabled())
{
// setup the rectangles
topRect = new Rectangle(0, 0, this.ClientSize.Width, marg.Top);
lefRect = new Rectangle(0, 0, marg.Left, this.ClientSize.Height);
rigRect = new Rectangle(this.ClientSize.Width - marg.Right, 0, marg.Right, this.ClientSize.Height);
botRect = new Rectangle(0, this.ClientSize.Height - marg.Bottom, this.ClientSize.Width, marg.Bottom);
// Fill Rectangles
g.FillRectangle(blackBrush, topRect);
g.FillRectangle(blackBrush, lefRect);
g.FillRectangle(blackBrush, rigRect);
g.FillRectangle(blackBrush, botRect);
}
blackBrush.Dispose();
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == welcome_page.VistaGlassEffect.VistaApi.WM_NCHITTEST // if this is a click
&& m.Result.ToInt32() == welcome_page.VistaGlassEffect.VistaApi.HTCLIENT // ...and it is on the client
&& this.IsOnGlass(m.LParam.ToInt32())) // ...and specifically in the glass area
{
m.Result = new IntPtr(welcome_page.VistaGlassEffect.VistaApi.HTCAPTION); // lie and say they clicked on the title bar
}
}
private bool IsOnGlass(int lParam)
{
// sanity check
if (!this.IsGlassEnabled())
{
return false;
}
// get screen coordinates
int x = (lParam << 16) >> 16; // lo order word
int y = lParam >> 16; // hi order word
// translate screen coordinates to client area
Point p = this.PointToClient(new Point(x, y));
// work out if point clicked is on glass
if (topRect.Contains(p) || lefRect.Contains(p) || rigRect.Contains(p) || botRect.Contains(p))
{
return true;
}
return false;
}
void buttn()
{
}
private void Form2_Load(object sender, EventArgs e)
{
int width = panel1.Width;
int height = panel1.Height;
System.Uri u = new Uri(@"Z:\B090105\Teja\C2\teja.avi");
video = Video.FromUrl(u);
video.Owner = panel1;
video.Play();
panel1.Size = new Size(width, height);
//this.apply();
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
//SpVoice sp = new SpVoice();
//sp.Speak("Who is this bich", SpeechVoiceSpeakFlags.SVSFlagsAsync);
//sp.WaitUntilDone(Timeout.Infinite);
}
}
}
Reply Me fast please
|
|
|
|