|
I have a ListView in details view. I need the item to be in a different position than the default one so I have written de code for DrawItem event. The items show in the correct position but when I select one and move to another one the control doesn't refresh its contents very well.
This is the code in the DrawItem event
Rectangle r = e.Item.Bounds;<br />
<br />
int charIndex = this.richIzquierda.GetFirstCharIndexFromLine(Convert.ToInt32(e.Item.Tag));<br />
<br />
r.Y = this.richIzquierda.GetPositionFromCharIndex(charIndex).Y;<br />
<br />
if (e.Item.Selected)<br />
{<br />
e.Graphics.FillRectangle(Brushes.Blue, r);<br />
e.Graphics.DrawString(e.Item.Text, e.Item.Font, new SolidBrush(Color.White), r);<br />
e.DrawFocusRectangle();<br />
}<br />
else<br />
{<br />
e.Graphics.DrawString(e.Item.Text, e.Item.Font, new SolidBrush((sender as ListView).ForeColor), r);<br />
}
This is the control shown on screen Link
How can I fix this problem? Thanks
|
|
|
|
|
How to Create New File In C#.net
Hello All,
I need to create New file .cs Extension(by coding (serverside)) and Paste The On String On It Anyone tell me how to Do it
|
|
|
|
|
/// write
TextWriter tw = new StreamWriter("test1.cs", false, Encoding.GetEncoding("ISO-8859-15"));
tw.WriteLine("//...some code ....");
tw.Flush();
tw.Close();
/// read
TextReader tr = new StreamReader("test1.cs");
string Buffer = mTextReader.ReadToEnd();
// .. whatever you wish with the whole file stored in the 'Buffer'
VirtualVoid.NET
|
|
|
|
|
I am using .net 1.1.
In my application...I am not getting my grid refreshed if i run it with out any break points.Buti am getting the right data if i use break point in the application...Any body can help me????
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
{
CrystalReport1 myReport = new CrystalReport1();
string conString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\\..\\123.mdb";
DataSet ds = new DataSet();
OleDbConnection con;
con = new OleDbConnection(conString);
string sql = "select * from ali";
OleDbDataAdapter db = new OleDbDataAdapter(sql, con);
db.Fill(ds, "ali");
myReport.SetDataSource(ds);//error--> The report has no tables.
crystalReportViewer1.ReportSource = myReport;
}
|
|
|
|
|
I don't know if the above question is correct, my english it's not very good.
however, i'm trying to make a safe thread call to a form :
I have declared a chatForms array with name (chatsAvailabel), so when i want to show
one of them i call the fuction ShowForm with a parameter that specify the index of the
form in the array.
delegate void ShowFormCallback(int index);
private void ShowForm(int index)
{
if (this.chatsAvailabe[index].InvokeRequired)
{
ShowFormCallback tmp = new ShowFormCallback(ShowForm(index));
this.chatsAvailabe[index].Invoke(tmp);
}
else
this.chatsAvailabe[index].Show();
}
but the problem occures when the InvokeRequired is true in if bolck, i must declare an
instance from the ShowFormCallback delegate to use with invoke, but how could i send
parmaeter index again along with this delegate instance.
thanks in advance
|
|
|
|
|
what about this style? :
private delegate void ShowFormCallback (int index);
private void ShowForm (int index)
{
if (this.chatsAvailabe[index].InvokeRequired)
this.chatsAvailable[index].Invoke(new ShowFormCallback(ShowForm),new object[] { index });
else
this.cahtsAvailable[index].Show();
}
VirtualVoid.NET
|
|
|
|
|
it's do work without error or exception, but the new showed form freeze(not rsponding) on screen which mean that the operation it's not thread safe.
|
|
|
|
|
maybe ShowDialog() can help ? (not just Show())
VirtualVoid.NET
|
|
|
|
|
You are not correctly using delegates. Try this:
private void InvokeShowForm(int index){
if(InvokeRequired){
Invoke(new ShowFormCallback(ShowForm), new object[]{index}));
}
else{
ShowForm(index);
}
}
public void ShowForm(int index){
chatsAvailable[index].Show();
}
File Not Found
|
|
|
|
|
Hi
I am developing a windows application which is having login and other pages as winforms.
In the login page I having an option for the user to change his password. If i click that change password button Im openning the change password URL in a webbrowser control. In that user will be asked to first login, and after login user will directed to change Password screen. But when the user logged in and closed that window and if the user clicks again the changepassword button then webbrowser control directing hime to change password screen instead of Login page. (is like kinda cached page). but i tried of clearing cache, used Activex control nothing works out.
Finally i saw the everytime i open the URL usign webbrowser control it is creating a Hidden IE window. (usign spy++). so that webbrowser is directing to the alredy opened page. How to close that hidden window? can i use its handle to close that one or any other solution here?
Thanks in Advacne
Srini
|
|
|
|
|
[DllImport("user32.dll")]
static extern bool CloseWindow(IntPtr hWnd);
[DllImport("user32.dll")]
static extern System.IntPtr FindWindow(string lpClassName, string lpWindowName);
private void button1_Click(object sender, EventArgs e)
{
string lpClassName = "WindowClass1";
string lpWindowName = "MyWindow1";
IntPtr hWnd = FindWindow(lpClassName, lpWindowName);
CloseWindow(hWnd);
}
|
|
|
|
|
Thanks for the reply, But this doesn't help, Still the Browser directing URL to logged in page instead of Login page.
I am using the code like this
CloseWindow(frmChange.axWebBrowser.Handle);
|
|
|
|
|
i am not able to update the changes made in SQl database using C# DataAdapter and binding sources
|
|
|
|
|
niting85 wrote: i am not able to update the changes made in SQl database using C# DataAdapter and binding sources
Some code would be useful.
|
|
|
|
|
hi
i'm not sure, but maybe you haven written an
UPDATE SQL string.
if you want to update your database, you have to
use TableAdapter.Update(), and if there is no
UPDATE SQL string, you got an error.
but as i wrote i'm not sure, because i'm
not good in SQL an databases generally
hope this helps you
greetz pdluke
(\_/)
(O.O)
(> <) <---- Put the evil bunny in your sig, help him acheive "WORLD DOMINATION!"
|
|
|
|
|
I have datagridview , so I want to add to it virtual column that appear
auto number at run time ! I mean ("when the result of search is 3)
I want to show in this column (this coumn not in database )only at run time
1
2
3
|
|
|
|
|
hi!
when u drag a datagridview control from toolbox and then draw ..now right clkk on the datagridview control and set the property like autogenetratecolumn "false"..now from this way u can add columns dynamically..
saeee
|
|
|
|
|
You are given a console program in both VB and C# that uses a class CElevator
(ElevatorAppAssign).
The main modules are in the assign directory class files.
Below is a discussion of that for VB; the one for C# is similar.
This discussion will show what is needed to write the class CElevator (in both VB and
C#).
When this class is complete, add it to your projects, and then run the projects.
Hand in the code for CElevator and the output (one set for VB, one set for C#).
An explanation of the application code follows
The main module starts with:
Sub Main()
Dim anElevator As CElevator = New CElevator(0, 10, 8)
The class CElevation should have only one constructor that takes three parameters:
(1) lowest floor number
(2) highest floor number
(3) maximum number of passengers that can be on the elevator
anElevator.Status()
The method Status should output to the screen text with the following format:
The elevator is at floor XX, with YY persons
Console.WriteLine("At floor {0}", anElevator.Floor)
Console.WriteLine("Number of persons in elevator is {0}", _
anElevator.Occupants)
Console.WriteLine()
The property Floor should return the floor number the elevator is on, an integer.
The property Occupants should return the number of persons on the elevator.
The above two properties should not be capable of setting these values; only returning
them.
anElevator.Enter(3)
anElevator.Enter(2)
anElevator.Leave(1)
Console.WriteLine("Number of persons in elevator is {0}", _
anElevator.Occupants)
Console.WriteLine()
The method Enter(noPass) tries to place noPass additional passengers on the elevator.
The method Leave(noPass) tries to remove noPass passengers from the elevator.
These methods must guard against having above the maximum number of passengers on
the elevator, or less than 0 passengers on the elevator.
The Enter method should allow as many passengers as possible to enter the elevator.
In particular, if the elevator is full, print the console message:
"Elevator full, so no one entered"
If there are more people trying to enter the elevator than space permits, allow whatever
number can enter, and print the console message:
"Only allowed XX persons to enter"
If there is room for everyone to enter, no message should be printed.
Similarly, the Leave method: should allow as many passengers as possible to leave the
elevator.
In particular, if the elevator is empty, print the console message:
"Elevator empty, so no one left"
If there are more people trying to leave the elevator than are on the elevator, allow all the
passengers to leave, and print the console message:
"Only have XX number of persons leaving"
If there is room for everyone to leave, no message should be printed.
anElevator.GoToFloor(3)
anElevator.GoDownOneFloor()
anElevator.GoDownOneFloor()
anElevator.GoUpOneFloor()
Console.WriteLine("At floor {0}", anElevator.Floor)
Console.WriteLine()
The method GoToFloor (fno) attempts to take the elevator to floor number fno.
The value of fno must be legal; if at attempt is made to go above the maximum floor
number, print the console message:
"Trying to go past top floor"
Similarly, if an attempt is made to go below the minimum floor number, print:
"Trying to go below bottom floor"
In both of the above cases, do not move the elevator.
No message is needed for a legal elevator move.
The methods GoDownOneFloor, and GoUpOneFloor have obvious meaning.
Again, you must guard against illegal floors. In particular, If GoDownOneFloor tries to
go below the minimum floor number, print the console message:
"Trying to go below bottom floor"
If the method GoUpOneFloor tries to go past the maximum floor number, print:
"Trying to go above top floor"
anElevator.GoToFloor(5)
Console.WriteLine("Time to get to floor 9 is {0:F2} seconds", _
anElevator.TimeToFloor(9))
The method TimeToFloor(fno) returns the number of seconds it will take to go from the
elevator’s current floor to floor fno. Your class should contain an attribute timePerFloor
whose constant value is 2.5 seconds (a double). Use this for your computation.
anElevator.Empty()
Console.WriteLine("It is " _
& anElevator.IsEmpty.ToString.ToLower _
& " that the elevator is empty")
Console.WriteLine("It is " _
& anElevator.IsFull.ToString.ToLower _
& " that the elevator is full")
anElevator.Status()
Console.WriteLine()
The method Empty should have all passengers leave the elevator.
Similarly a method Full should result in the elevator having its maximum number of
passengers.
The property IsEmpty should return True or False, a Boolean, depending on the
occupancy of the elevator. Similarly, the property IsFull should return True or False, a
Boolean, also depending on the occupancy of the elevator. These two methods should
only return values.
The remaining code in this module tests that various methods do not behave incorrectly;
no new methods are used.
|
|
|
|
|
We won't do your homework for you - try yourself, and ask a specific question when you get stuck
|
|
|
|
|
I have created a datagrid in C# Windows Application and i want to place a checkbox in it.I have tried this link
http://www.windowsforms.net/FAQs/default.aspx?PageID=2&ItemID=537&CategoryID=3&tabindex=3
I am able to place the checkboxes but can't make tht checkboxes working i.e.can't able to select and deselect the checkbox items.
i.e. the checkbox functionality is not enabled.
I know this in Web Application but i m here using WINDOWS APPLICATION.
How can i do this?
|
|
|
|
|
I wanna assign a textbox object to another text box object, so that to accomplish, all the properties and values present or assigned to that textbox object will be copied to this textbox object. For example, I have a textbox with it's location as (x=10,y=10) and name be "First" then another's as (x=100,y=100) and "Second". Now if i assign the first object to second object... what will happen is, it will just make a reference to the previous one. When printing.. both will point to first object only. What i want is all the properties of first object should be copied to second object and if i change some values of the second object.. it should accept those values. [I wanna have both the textbox printed in the mentioned locations]. How can this be achieved?
|
|
|
|
|
You can try cloning the object, if it implements the ICloneable interface. Otherwise, I don't see any other way than copying the properties yourself, either in code or via reflection.
|
|
|
|
|
Hi i tried my level best to achieve the task with the help you provided. But couldn't get the desired. Here is the snippet of code that i use. Can u please use this code to achieve the task with the help you provided [Icloneable interface or reflection or copying properties through code]?
TextBox tbxFirst = new TextBox();
TextBox tbxSecond = new TextBox();
tbxFirst.Location=new Point(100,100);
tbxFirst.Text = "First";
tbxSecond.Location=new Point(10,10);
tbxSecond.Text="Second";
tbxSecond = tbxFirst;
this.Controls.Add(tbxSecond);
this.Controls.Add(tbxFirst);
What i want is to have both the textboxes at the specified location with its text.
|
|
|
|
|
dear fellows i hope u will all be fine
it is my first question on any forum. so i do not know how to put a question and how to get an answer.although i have read the instructions of how to get the answer yet i m not sure.. so at least one person answer my question.
i want to add a menu item which should display in the menu when user right click on a file and some when user will point to this menu item. some other options to be shown. how to do this.pl help me (by sending code) or some reference material or help topic.
waiting for your kind response
A.Nadeem
|
|
|
|