|
I'm using a popup dialog with a listbox to allow the user to set/change a parameter. In addition to selecting a value and clicking OK I'd like to allow the user to be able to doubleclick on a value and have it close with the doubleclicked value used. The problem is that I can't tell the difference between a doubleclick on an item in the box, and one in empty space below the last valid entry. IN the latter case I want to do nothing. My current handler instead returns with whatever the last valid selection was.
<br />
private void OnDoubleClickPriority(object sender, System.EventArgs e)<br />
{<br />
m_sSelectedText = m_lbPriority.GetItemText( m_lbPriority.SelectedItem );<br />
Close();<br />
}<br />
|
|
|
|
|
In the MousDown event of the listbox call the IndexFromPoint function of the ListBox with the given coordinates and assign it to some member variable. In the DoubleClick handler you can then check if an appropiate index was hit (if I remember right IndexFromPoint return -1 if no item was hit).
|
|
|
|
|
Thanks. That worked perfectly.
|
|
|
|
|
Can some one please helpe me!
I want to bulid a com addin for PowerPoint that overrides the save command to display a custom SaveAs dialog. When the user has selected the save location i want to call the "SaveAs" method of the Presentation object. The problem is that it casts an exception (unknown member). Is this a bug in PowerPoint or is there an workaround?
Thanks
Be paragmatic
|
|
|
|
|
I am working on a server application and I want it to start with the windows startup. Can somebody tell what I should do?
Thanx anyways.
|
|
|
|
|
There are 3 ways to achive this.
1. add a shotcut in the startup folder in the programs menu (only works if the user is logged on)
2. Add the application to the run folder in the registry. (HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run)
3. create it as a Windows service. there is a template for creating a windows service project in VS.net
Hope that was helpfull..
Be pragmatic
|
|
|
|
|
Hi, I want to bold all the dates stored in my database for this purpose I am using the following code of lines
string [] str;
char []sperator = {'/' ,' ' };
foreach ( DataTable table in dataset.Tables )
{
foreach ( DataRow row in table.Rows )
{
s1=(row["D"]).ToString();
str=s1.Split(sperator);
this.monthCalendar1.MonthlyBoldedDates = new System.DateTime[]
{
new System.DateTime
(Convert.ToInt32(str[2].ToString()),Convert.ToInt32(str[0].ToString()),Convert.ToInt32(str[1].ToString()))
};
}
}
but this code only bold the last date read from the database. Please help me in this regard I will be very thankful to u.
|
|
|
|
|
Try it this way (havent compiled it so it probably has some minor errors):
string [] str;
char []sperator = {'/' ,' ' };
ArrayList datesList = new ArrayList();
foreach ( DataTable table in dataset.Tables )
{
foreach ( DataRow row in table.Rows )
{
s1=(row["D"]).ToString();
str=s1.Split(sperator);
datesList.Add(new System.DateTime(Convert.ToInt32(str[2].ToString()),
Convert.ToInt32(str[0].ToString()), Convert.ToInt32(str[1].ToString())));
}
}
DateTime[] datesArray = new DateTime[datesList.Count];
datesList.CopyTo(datesArray);
this.monthCalendar1.MonthlyBoldedDates = datesArray;
|
|
|
|
|
How do I get the database schema once I have set up an OdbcConnection? Primarily I need a list of tables and columns in the database. My App needs to be able to connect to any ODBC datasource and work out what tables and columns it contains.
TIA
|
|
|
|
|
I have started to use the ODBC calls and P/Invoke as the Odbc stuff is .Net is sorely lacking.
Still can't get it work though.
IntPtr henv;<br />
short ret;<br />
<br />
ret = SQLAllocHandle(SQL_HANDLE_ENV, (IntPtr)SQL_NULL_HANDLE, out henv);<br />
if(ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO)<br />
{<br />
ret = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION,(IntPtr)SQL_OV_ODBC3, 0);<br />
if(ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO)<br />
{<br />
IntPtr hdbc;<br />
ret = SQLAllocHandle(SQL_HANDLE_DBC, henv, out hdbc); <br />
if(ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO)<br />
{<br />
ret = SQLConnect(hdbc, dsn, SQL_NTS, null, SQL_NTS, null, SQL_NTS);<br />
if(ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO)<br />
{<br />
IntPtr hstmt;<br />
ret = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, out hstmt);<br />
if(ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO)<br />
{<br />
ret = SQLTables(hstmt, null, SQL_NTS, null, SQL_NTS, null, SQL_NTS, null, SQL_NTS);<br />
if(ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO)<br />
{<br />
StringBuilder tableName = new StringBuilder(256);<br />
int tableNameLen;<br />
ret = SQLBindCol(hstmt, 2, 1, tableName, 256, out tableNameLen); <br />
if(ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO)<br />
{<br />
while(SQLFetch(hstmt) == SQL_SUCCESS)<br />
{<br />
Console.WriteLine(tableName + ":" + tableNameLen.ToString());<br />
}<br />
}<br />
}<br />
<br />
ret = SQLFreeHandle(SQL_HANDLE_STMT, hstmt);<br />
}<br />
<br />
ret = SQLDisconnect(hdbc);<br />
}<br />
ret = SQLFreeHandle(SQL_HANDLE_DBC, hdbc);<br />
}<br />
}<br />
ret = SQLFreeHandle(SQL_HANDLE_ENV, henv);<br />
}
The SQLFetch will be called as many times as there are tables in the dsn but the dsn is empty and tableNameLen is -1.
Rugby League: The Greatest Game Of All.
|
|
|
|
|
pardon my ignorance, but I am very new to Windows form development and am not sure how to get his done. And I can't seem to find the correct solution through any of the forums or msdn.
So here is my question: I have created a form with a datagrid on it. I want to open up a new form which when you double click on the record in the datagrid from the parent will open up a data entry screen with all of the information in it.
Thanks in advance.
mike
|
|
|
|
|
The method:
You must create the form you wnto to be a parent example: called it Form2.
Then you place the controls on it, wich you need, and declared it Public or create a get/set property for them
Last step, where you need to see the new window, place a code like this:
<br />
Form2 f2=new Form2();<br />
<br />
f2.textBox1.Text="This works!";<br />
.....<br />
f2.Show();
<br />
I think that's you need to do.
|
|
|
|
|
There's a few different ways to do this. First make sure you have the event hooked up to the DataGrid's Click or DoubleClick event, whichever you prefer.
this.dataGrid1.DoubleClick += new System.EventHandler(this.dataGrid1_DoubleClick);
Next set up your handler method (visual studio inserts this stub in for you very easily)
<br />
private void dataGrid1_DoubleClick(object sender, EventArgs e)<br />
{<br />
}<br />
Now let's say that in your parent datagrid, the first Column in the datagrid is an integer Invoice number. You want to retrieve that information for that invoice number to open up the second Data Entry screen.
<br />
private void dataGrid1_DoubleClick(object sender, EventArgs e)<br />
{<br />
int invNumb = Convert.ToInt32(dataGrid1[dataGrid1.CurrentRowIndex, 0]);<br />
DataSet myInvoiceInformation = GoGetMeTheInvoice(invNumb);<br />
<br />
MyNewInvoiceForm invFrm = new MyNewInvoiceForm();<br />
invFrm.InvoiceInfoToShow = myInvoiceInformation;<br />
<br />
invFrm.ShowDialog();<br />
}<br />
In this very very simple example, we create a dataset with the information, assuming you have some method that retrieves the information. Your Data Entry form has a Public Property of type DataSet that allows you to set the dataset with the invoice information. You could also write another constructor to your Data Entry form so you don't have to write 2 lines of code.
Also, you can set up the DataGrid with a TableStyle if you want, so that your identifying information is always in the first column of the datagrid, but it's hidden. In my case I just set the width of the first column to 1px.
Hope this simple example helps.
|
|
|
|
|
Hi, I have this class in which I start a worker thread in the constructor. The thread is a loop and I want it to stop when I close the application in which I created it.
I've tried to put an Abort command in the class' destructor but that didn't seem to work... does anyone know the right way to do it?
Thanks!
|
|
|
|
|
If you don't care about the the thread shutting down at critical points, just set the IsBackground property to true . That'll kill the thread automatically when the application shuts down.
If that doesn't work or you can't stop the thread at arbitrary points, you need to have some sort of signaling mechanism, like posting a message to the thread and the thread, when it gets to processing the message, breaks out of the loop.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi;
This is what I'm trying to do:
I want to populate a listview on another from and then after quitting this form I could see the changes Ive made.
so I wrote a method to do that for me:
<br />
public void populateListView(ref ListView lview, string dbFilePath, string tableName)<br />
{<br />
Connection myConnection = new Connection();<br />
myConnection.ConnectionString = dbFilePath;<br />
myConnection.Open();<br />
<br />
Recordset rs1 =myConnection.Execute("select * from " + tableName);<br />
<br />
rs1.MoveFirst();<br />
for (int i=0; i<rs1.Count; i++)<br />
{<br />
ListViewItem lv=new ListViewItem();<br />
ListViewItem.ListViewSubItem lvs = new ListViewItem.ListViewSubItem();<br />
<br />
for (int j=0;j<rs1.Fields.Count;j++)<br />
{<br />
if (j==0)<br />
{<br />
lv.Text=rs1.Fields[0].ToString();<br />
lv = lview.Items.Add(lv);<br />
}<br />
else<br />
{<br />
lv.SubItems.Add(rs1.Fields[j].ToString());<br />
}<br />
}<br />
<br />
rs1.MoveNext();<br />
}<br />
<br />
rs1.Close();<br />
<br />
myConnection.Close();<br />
<br />
foreach( System.Windows.Forms.ColumnHeader c in lview.Columns)<br />
{<br />
c.Width = -2; <br />
}<br />
}<br />
as you see im populating a listview from a database.
I get an error saying marshal_reference . . .
do you guys have any idea?
P.S I did search the codeproject but the solutions were a little complex.
Thanks
|
|
|
|
|
hi
Can anybody tell me Equivalenet Space() function in C#.net
THis is very urgent.
Functinality of this function is to allocate space autmatically
Is there any equvalent function
as we declare in Space function
|
|
|
|
|
Where do you need to allocate space? What does the Space function do? Return a string with the number of spaces equal to the parameter passed to the Space function?
That should be very easy to do
string Space(int count)
{
return new string(' ', count);
}
Hope this helps?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
The equivalent of:
x = Space(3)
is:
x = string.Empty.PadLeft(3);
(example produced with our Instant C# VB to C# converter)
David Anton
Tangible Software Solutions
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# Converter and the Instant VB C# to VB.NET Converter
|
|
|
|
|
Hi ... i have a listbox with lots of names and i need to sort it out in alphabetical order. from A to Z and from Z to A. I heared about bubble sort algorithm but i could understand it very well.
i apreaciate any help
Thanks
|
|
|
|
|
|
Sure take a look at sort algortihms... to make boss/ teacher /whoever happy right now, use ListBox.Sorted property. It does exacly what you need IMHO.
hmm but where is option to reverse sort order?? If you won't find any, use Array.Reverse on sorted items.
David
|
|
|
|
|
I am having a hard time finding anything through searches for this. I am looking for information to help me with this project at work. I need to create a webform that is used to enter a persons information, then the user clicks a button. When they click the button it should pass the information and populate a word document that can be viewed and printed.
Thank You
Scott Moore
|
|
|
|
|
Word Interop is pretty much your only choice here, (I believe and would be happy to be proven wrong I must say), but it's horrible and heavyweight at the server as it essentially involves running MS Word in memory on the Web Server.
A Google[^] search should give you some direction...
Rhys
A bus station is where a bus stops. A train station is where a train stops. On my desk I have a workstation...
Vampireware /n/, a project, capable of sucking the lifeblood out of anyone unfortunate enough to be assigned to it, which never actually sees the light of day, but nonetheless refuses to die.
|
|
|
|
|
I have the same problem! I can find all kinds of information about creating a Windows App to do this, but when I build a Web Based App - I always get the error: Could not open macro storage. This is driving me crazy because I can't find info about what permission need to be set to get around this.
I have been able to build a Word Doc using the File Object and FileStream Class, but then I lose a a lot of functionality which comes with the Application Object. For example I can't create a pagebreak where I need to.
Let me know if you figure this out!
Thanks
Lynnette
|
|
|
|