|
How do I know if the current cell is the header cell when I override the paint method?
thanks!!
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
As said not trivial.
The grid has a GetCellBounds function which you can use to determine the bounds of a cell. The problem is that this doesn't include header cells. But if you have the bounds of the cells in the first row you should be able to calculate where the header 'should' be. If you have this you will have to repaint every header cell everytime Paint is called.
|
|
|
|
|
I don't think I get it!! If you are asking about customizing the column header at design time, just look at the properties window. Look for a property named "ColumnHeaderDefaultCellStyle". There you can change the color, font, formatting, and anything else you want in the Column headers appearance at design time. There are also some other properties in the properties window that you can change (eg. BorderRaised property). If your question was about changing the look of a certain column header at run time, you can use either use "DataGridView1.Columns[X].HeaderCell" (where X is the column number), to access the header cell directly, or one of the followings:
DataGridView1.ColumnHeadersBorderStyle;
DataGridView1.ColumnHeadersDefaultCellStyle;
to change the border style and the cell style respectively at run time.
I hope that solves it. If it doesn't, post me more details of what you need, maybe I can help.
|
|
|
|
|
hi,
actually I am using the DataGrid control (not DataGridView) from the vs2005. I know is not recommanded. but for some history reason I have to use it. also I bind the grid to a arraylist. I want show the triangle icon when I sor the selected column. I just want to simple sort the arraylist and use refresh to update the binding. it works, but I can not see the little triangle.
do you have any idea about this???
Thanks a lot!
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
Well, now I can see your problem. I'm not sure this will be easy but I think if you have to override th OnPaint event you can put an if statement at the begining to check for the CurrentCell or RowIndex properties to make sure that you are in the header row, but I don't know how that be of any help.
Another way I can think of doing this is by putting a + or - in the header cell's text;P, I know it's silly but I can't think of anything else right now!! I even tried to use the ascii code to put the triangle (Codded 1E for up & 1F for down) in the text but it doesn't work!
while I was digging up I also found "dataGrid1.TableStyles[0].GridColumnStyles[x]" property!! maybe it will be of some assistance.
You may also get the ClientRectangle, or the Displayrectangle of the DataGrid. Then add the widthes of the columns before the selected column to 0 and this will be the location of your column. Then use the System.Drawing to draw your rectangle in the header's area.
But what's worth all this effort?!!
-- modified at 17:46 Tuesday 16th May, 2006
|
|
|
|
|
Hello everyone,
I have inherited a piece of code that is using a resx file to embed icon in it. These icons are then used in a class. The icon node looks something like this
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 ....
Well, I have never done anything like this before, but i need to add a "+" icon to my app. How do I go about getting the "binary value" for my icon.
Any help would be tremendously appreciated.
Thanks
Sameer
|
|
|
|
|
There are several ways to get resources into your project. One way is the following:
1. Add the icon to your project (rightclick -> Add Existing file)
2. Change its 'Build Action' property to 'Embedded Resource'
3. In your code write the following:
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
Stream inputStream = assembly.GetManifestResourceStream("YourNamespace.YourFile.ico");
Icon yourIcon = new Icon(inputStream);
The code assumes that the icon is in the same assembly as the code which accesses it. 'YourNamespace' is the one you can set in the properties of each project.
|
|
|
|
|
I like to preview some Image objects in 64*64 format in some kind of control. Is there any .NET control for that.
I only find the ListView control but with that I only can preview pictures in 16*16 format and that is to small for me…
_____________________________
...and justice for all
APe
|
|
|
|
|
With some modifications the control in this article[^] might fit for you.
|
|
|
|
|
hello all,
I want to install a windowsservice using dos prompt(NOT VS commmand prompt) how tot do this?
any solutions will be appriciated
regards
GV Ramana
|
|
|
|
|
The only difference is that the VS command prompt has some additional items in the PATH environment variable. All you need to do is refer to the full path of InstallUtil.exe:
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\InstallUtil.exe or add C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 to the path yourself.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
Just put the InstallUtil.exe and InstallUtilLib.dll where you want them, and run the InstallUtil from the command prompt as you would any other dos based program.
To intall: InstallUtil.exe ServiceAssembly.exe
and
To unintall: InstallUtil.exe /u ServiceAssembly.exe
----------
There go my people. I must find out where they are going so I can lead them.
- Alexander Ledru-Rollin
|
|
|
|
|
Hi, I have the following strange behaviour
I have an abstract base class in which a delegate is availlable. I the derived class i need to call the connected function. But that results in the following compliation error:
The event 'winFromsTest.MyBase.Callback' can only appear on the left hand side of += or -= (except when used from within the type 'winFromsTest.MyBase')
Does anybody knows a reasson why i can't call the delegate from the derived class('s)
codito ergo sum
|
|
|
|
|
Because you have declared it as an event which is protected from invalid access. If you want to raise the event from an inheriting class then add a protected method to your base class as a helper function:
protected virtual void OnCallback(EventArgs e){
if (Callback != null)
Callback(this, e);
}
base.OnCallback(EventArgs.Empty);
|
|
|
|
|
Thanks,
So it just like i just found out, to prevent you to shoot yourself in the foot
codito ergo sum
|
|
|
|
|
How to me "to catch" VK_DOWN in DataGrid?
Help, please.
|
|
|
|
|
hi again,
i can read the BytesToRead value but couldnt use Read or ReadLine yet ;(
what may be the problem ?
if (Convert.ToInt32(sp.BytesToRead.ToString()) > 0)
{
MessageBox.Show(sp.BytesToRead.ToString());
textBox1.Text = sp.ReadExisting();
//or textBox1.Text = sp.ReadLine();
}
doesnt work ...
help me please
|
|
|
|
|
First, why are you doing this?
Mehmet Fatih Akbulut wrote: if (Convert.ToInt32(sp.BytesToRead.ToString()) > 0)
All you're doing there is: converting an integer to a string, then parsing that string back into an integer. That is useless, there is no need to convert to a string. Just use
if(sp.BytesToRead > 0)
{
...
}
Second, what error are you getting? Did you call sp.Open() before trying to read the data?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Islamic Domination: Coming to a Jewish state near you!
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Dear Experts
I have an Act.X in my source code,showing a map and without any routine for print it context.I guess I can print its context using Draw method and passing a printer device context to it.But I can't find any way to take a printer device context else using win32 API.Is there any way in .NET framework (C#)and managed code to do it?
Any help will be highly appreciated
Regards
Reza
|
|
|
|
|
How to identify the enter key is pressed inside a textbox
Deepak
|
|
|
|
|
hi Deepak Dhongde! =)
if your inherting a textbox override the OnKeyDown method & if not attach a handler on the KeyDown event of your textbox, then add this condition:
if (e.KeyData == Keys.Enter)
{
}
hope this helps!
microsoc
|
|
|
|
|
In the KeyUp event of this text box you can check the KeyCode property of KeyEventArgs object,using this enumeration System.Windows.Forms.Keys.Enter.
here is a sample code
private void textBox1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode==System.Windows.Forms.Keys.Enter)
MessageBox.Show("successful");
}
|
|
|
|
|
The RichText and the TextBox controls have the property Lines that of type string[]. Any idea how the controls handle the resizing of the Array?
I want to know because I want to use an Array, which will hold properties for each Line of the TextBox control.
Or do you have any suggestion what should I do best?
|
|
|
|
|
I seriously doubt these controls store the array - the property most likely convert to and from the "native" format when you call the get or set method.
So the solution is to use a collection:
List<string>
|
|
|
|
|
You could store each of your lines in an ArrayList, which autosizes for you when you Add or Remove . As long as you only put strings in there, you can use 1 simple line when you want to assign the lines:
string [] lines = (string[])myArrayList.ToArray(typeof(string));
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|