|
When you set GridLines = true in the ViewList the grid lines don't match up with the column.
How do I fix this?
Thank you
|
|
|
|
|
Years ago I used to muck around with Basic and I used to draw things just using commands like "plot x,y " and whatever.
I'd like to do something similar in VS but I'm not sure how. I *think* I have to make a window that can be used to draw to, but I'm not sure how, and I also need to be able to write pixels or something to that effect as well.
All I need is a very basic platform so I can start, because I can work up from there, but until then, I don't have a clue, well, I think I need to use GDI+ but thats all I know.
July is perseverance month
|
|
|
|
|
I would start creating an empty Form and adding a Panel into it. The Panel will be the area your graphic will be drawn to. But the actual painting shouldn't be done directly to that panel - you should do it on a Bitmap object which you can than draw onto the Panel. This is known as double buffering and is handy because the windows are redrawn rather often (e.g. when minimized/maximized or just another window moving over it). This way you will not have to 'remind' every draw operation.
To fill the Bitmap with life you have to create a Graphics object of it. This object will than have all kinds of drawing functions. To set simple pixels you can even use the SetPixel function right on the Bitmap object.
I think its also a good idea to (instead adding just a plain Panel to your Form) inherit from Control or UserControl and encapsulate the needed drawing operations into a seperate class.
The basic startup code could look like the following (not tested):
public class MyPlot : Control {
private Bitmap _buffer;
public MyPlot() {
ClearBuffer();
}
private void ClearBuffer() {
_buffer = new Bitmap(base.Size);
this.Invalidate();
}
protected override OnResize(EventArgs ea) {
ClearBuffer();
}
protected override OnPaint(PaintEventArgs pea) {
if (_buffer != null)
pea.Graphics.DrawImageUnscaled(0, 0, _buffer);
}
public void DrawCommand(string[] commands) {
using (Graphics g = Graphics.FromImage(_buffer)) {
for (int i = 0; i < command.Length; i++) {
DrawCommand(commands[i], g);
}
}
}
private void DrawCommand(string commands, Graphics g) {
g.DrawLine(Pens.Black, 5, 5, 10, 10);
g.FillRectangle(Brushes.Red, 8, 17, 15, 20);
}
}
Add this Control onto a form and begin to send commands to it .
|
|
|
|
|
hi there. I have a project to make and i'm a litle confused. Between a Browser (like IE or Firefox) and the web server IIS i have to do something (application, Server, module ...) that recognizes a PDA and if so change HTML code or change the text inside it and then answer the request.
I need some kind of module or application that work with IIS and, if device is PDA, change the response to the browser.
The problem is that i have to change the text within the pages of all web sites...
I can configure web.config in ASP.NET on root of all web sites in IIS to recognize or filter PDA devices and i did a module with the help of a web service to change the web pages but this only works with pages that use aspnet_isapi.dll. The rest of the pages pass by this module.
This only works in WebService pages or WebApplication pages.
I need a "HTTP Runtime Support" of .NET with HttpHandler and HttpModule for all pages and not only for aspnet_isapi.dll.
ASP.NET
<httpmodules>
<add name="HelloWorldModule" type="WebServiceHTTPModule.HelloWorldModule, WebServiceHTTPModule">
The only way i think this is executable is by making a ISAPI filter for IIS but i need to program in c# for my project ...
.NET, C#.
Can you Help me !!! PLEASE
Sorry for my english.
Thank you for your time
Bruno Conde
countbruno@gmail.com
|
|
|
|
|
What is the best way to create thread safe generic dictionary. The only operations done by multiple threads are check if key exists, get value and add value.
I created a helper class that calls those methods internally, and uses lock inside the method. Is there a better way of doing it?
I know in non-generic versions you could do Hashtable.Synchronized, but generic dictionary doesn't offer this.
|
|
|
|
|
A "better" way of doing this would to use the ReadWriterLock, allowing multiple readers but single writers. And yeah, you'll need to implement all the methods yourself.
The problem with the built in .Synchronized versions of Hashtable and ArrayList is that naive developers assumed that you could create a synchronized version of the list, have one thread insert an item in the list, and have another thread iterate over it using foreach. BAD PRACTICE! Because using a foreach will iterate over the list without locking it (it can't lock it because it doesn't know when the consumer is done iterating over it). So the insert on another thread interrupts and foreach, causing an exception because the list can't be modified while iterating over the list with foreach.
In other words, you can't just assume a synchronized version of your list does takes care of all threading issues. The consumers of the list have to ensure proper synchronization.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Homosexuality in Christianity
Judah Himango
|
|
|
|
|
Thanks for suggesting ReaderWriterLock, I already looked into it before and it seemed what I wanted, but using lock was just easier.
I also knew about iteration problem, but I do not worry about that as I only need to insert and get data back.
|
|
|
|
|
Okay, I have had no luck and somehow I know this should be easy. I made an app that receives data and processes the info and does calculations, etc. But I can't get the data to write to anything on the form. I know how to use form button and such, but I want the app itself to write to a textbox, datagrid, whatever on the form. But I can't get it to work. Any help is greatly appreciated. I'm using Visual C# .Net. I can only get it to write to the console. HELP!
Thanks,
RABB17
|
|
|
|
|
That greatly depends on what Control you want to fill.
Moste controls (like TextBox, Label, GroupBox...) have a Text property where you can set a string to determine which Text is shown, e.g.:
myTextBox.Text = myCalculatedNumber.ToString();
To fill the DataGrid is a bit more complicated. You will have to create a DataTable, add columns to it, fill the rows and finally set the DataSource property of the DataGrid to this object:
DataTable dt = new DataTable();
dt.Columns.Add("First Column", typeof(int));
dt.Columns.Add("Second Column", typeof(string));
dt.Rows.Add(new object[] { 1, "First Row" };
dt.Rows.Add(new object[] { 2, "Second Row" };
dt.Rows.Add(new object[] { 3, "Third Row" };
myDataGrid.DataSource = dt;
|
|
|
|
|
String [] str = new String [8];
str[0] = "a1";
str[1] = "b1";
str[2] = "c1";
str[3] = "d1";
str[4] = "e1";
str[5] = "f1";
str[6] = "g1";
str[7] = "h1";
then i want to take input
for(int i = 0; i < 8 ; i++)
{
input = Console.ReadLine()
source1=str[i].CompareTo(input);
Console.WriteLine(source1);
if(source1 != 0)
{
Console.WriteLine("no");
Console.WriteLine(i);
}
else
{
Console.WriteLine("yes");
Console.WriteLine(i);
temp3 = i;
i = 9;
}
i always say no if i take input within the loop. and work correctly if i take input out of loop. but i want untill user give correct input it takes input again and again. how i will do this .
|
|
|
|
|
How the crap do I put a parenthesis in a string in C#???
I want to do this... string asdf="(";
/\ |_ E X E GG
|
|
|
|
|
Why not try before you ask? That is exactly how you do it. There is nothing special about having a paranthesis in a string. It's just like any other character.
---
b { font-weight: normal; }
|
|
|
|
|
how about in java?
/\ |_ E X E GG
|
|
|
|
|
String asdf = "(";
Same escape sequence rules in C, C++, C#, and Java.
|
|
|
|
|
Must be something else you are doing. That should work.
The only tricky character is the backslash. It is the escape character for non-printing and control characters, so you have strange constructions like:
string abcd = "\"\\\"";
That translates to a string containing double-quote backslash double-quote.
|
|
|
|
|
I'm trying to create a launcher program that will automatically update files for another program and then launch that updated program. The launcher and the main app have already been created as seperate VS .Net projects(.exe). My question is would it be possible to build the main app as a dll, reference it in the other project and then have the launcher update the dll and launch it? Any sort of help would be greatly appreciated.
Code first, ask questions later.
|
|
|
|
|
|
Hm. This provides the same sort of functionality I'm looking for, but since I've already wrote the auto-updater I'm just wondering if there is an easy way to integrate two projects so one can open the other. Both are .exes right now, I would like the internal problem to be a .dll.
|
|
|
|
|
What you want to do is called "late binding". Search on that term and you will find several articles.
|
|
|
|
|
Hello,
Is there a way of making a specific cell in the column of a Grid - ReadOnly.
Thank you.
|
|
|
|
|
Short answer: No.
Long answer: Uhmmm... well... yes. But its a bit complicated:
You will have to inherit from the DataGridTextBoxColumn and override the Edit function. Here you could throw an event with CancelEventArgs, catch it somewhere outside and determine from the CurrentCell whether it should be ReadOnly or not (and set the Cancel of the EventArgs).
|
|
|
|
|
Hello,
Is there a way to implement a div operation on two numbers?
I need the quotent result.
So if I have two decimals, and my result after division is 5.2, I need only 5.
Thank you
|
|
|
|
|
|
Thank you.
By the way, do you know how to format the decimal output to only 4 decimal points?
If I have:
decimal totalArea = (NetRes * DevRes);
how do I format totalArea to have 4 decimal points?
Thank you.
|
|
|
|
|
You don't format totalArea to 4 decimal digits. You could round it to 4 decimal digits, which is a bit different:
totalArea = Math.Round(totalArea, 4); Here you are changing the number itself. Also, you can convert to string with 4 decimal digits:
string area = totalArea.ToString("0000"); This last statement will fill area with the string representation of totalArea , with 4 decimal places. totalArea won't be modified and will keep all its digits.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|