|
Dear all,
I am making a window form and using 1 datagridview control on it. The datagridview itself supports auto sort, but it is only valid with all column type except image column.
Please give me your all solutions on this issue.
Thanks.
Banana
|
|
|
|
|
from where you are retriving image name.Regardless of any source(s).Just do one thing might it work.Take all the image name(hope all r unique) and store them in array list.Now sort the list and store all column base on image name.
Regards
Chintan
www.visharadsoft.com
(Nothing is so purify as KNOWLEDGE)
|
|
|
|
|
Thanks Chintan.Desai for your reply.
My problem is really that when my datagridview load all data completely, click on each column, except image column, and every things are ok. But when i click on image column, it is not active.
If I put all my data in array list and each column use 1 array list, we will have many array lists. This is quite difficult for managing code.
Please send me your all other suggestions
Thanks for all help.
Banana
|
|
|
|
|
No buddy,Arraylist is one type of container,so store every image name in that arraylist and then use Sort function from array list class and sort them.
Regards
Chintan
www.visharadsoft.com
(Nothing is so purify as KNOWLEDGE)
|
|
|
|
|
Thanks Chintan for your warm and kind help.
I solved my problem by using IComparer interface. I have a object and image is one of its many properties, I wrote a lass for compare to object, and property used for compare is the image type (each product have 1 image type).And the last, I create an array list and sort all this array follows my new class which implements from IComparer.
<br />
public enum SortDirection<br />
{<br />
Ascending,<br />
Descending<br />
}<br />
class ElementSorting : IComparer<br />
{<br />
<br />
private SortDirection m_direction = SortDirection.Ascending;<br />
<br />
public ElementSorting() : base() { }<br />
<br />
public ElementSorting(SortDirection direction)<br />
{<br />
this.m_direction = direction;<br />
}<br />
<br />
int IComparer.Compare(object x, object y)<br />
{<br />
<br />
ABCElement elementX = (ABCElement)x;<br />
ABCElement elementY = (ABCElement)y;<br />
<br />
if (elementX == null && elementY == null)<br />
{<br />
return 0;<br />
}<br />
else if (elementX == null && elementY != null)<br />
{<br />
return (this.m_direction == SortDirection.Ascending) ? -1 : 1;<br />
}<br />
else if (elementX != null && elementY == null)<br />
{<br />
return (this.m_direction == SortDirection.Ascending) ? 1 : -1;<br />
}<br />
else<br />
{<br />
return (this.m_direction == SortDirection.Ascending) ?<br />
elementX.Type.CompareTo(elementY.Type) :<br />
elementY.Type.CompareTo(elementX.Type);<br />
}<br />
}<br />
}<br />
Thanks
Banana
|
|
|
|
|
I generated columns and rows in a datagrid. when I click a button while the radiobutton is checked i was able to convert the cell backcolor.
My requirement is when i clicked the cell its rowindex, columnindex will get added to a listbox. which later will stored. My code snippet looks like this
private void dgv1_CellClick(object sender, DataGridViewCellEventArgs e)
{
foreach (DataGridViewRow row in dgv1.Rows)
{
if (radioButton1.Checked == true)
{
row.DataGridView.CurrentCell.Style.BackColor = Color.Black;
//Try to add the cell index to listbox collection item
//listBox1.Items.Add(row.DataGridView.CurrentCell.RowIndex);//it stores the index total row no. times
//listBox1.Items.Add(row.DataGridView.CurrentCellAddress);//need to reduce it to only one
}
help me.
|
|
|
|
|
hi,
I have two forms Form1 and Form2. On Form1 i have a data grid that has a data in 3 columns, now on button click i want to send data of first row to Form2 that has 3 textboxes, so that the text boxes have the corresponding values (for eg Name,City,Country). I tried to make 3 public properties and assign the values of the grid cells to them and then tried to call these properties on FOrm2 to populate the text boxes, but they show up empty, because to be able to access Form1's property, i need to declare and initialise Form1's instance, so each time a new instance is created, the property would contain null values.Please help
|
|
|
|
|
u can pass the instance of first form to second form in second forms constructor.
rahul
|
|
|
|
|
Except that would be nasty...
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
public partial class Form2 : Form<br />
{<br />
Form1 frm1;<br />
public Form2()<br />
{<br />
InitializeComponent();<br />
frm1 = new Form1();<br />
}<br />
Is that what u wan to say ?
|
|
|
|
|
No, that is an utter disaster, it cannot work. The Form1 inside form2 is completely irrelevant to the Form1 that you are working with.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I assume they are not called that....
If you want to pass data from form1 to form2, pass it through the constructor or through properties, if you want to pass data from the child to the parent, set up delegate methods to do so. Whatever you do, set up the smallest scope properties you can, i.e. set up a string property to set the text of a textbox, rather than making the textbox itself public.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi Chris....thts what I precisely did....i created 3 public properties on Form1 each to capture cell values of the grid data and then in Form2 I created an instance of Form1 and using it i accessed those properties, but since each time the Form2 loads, it would create a new instance which wud be null, the text boxes are empty. Now, do we have a way to modify this to work
|
|
|
|
|
Yep - that's the issue. A new instance of Form1 has nothing to do with the instance in use in your program. I recommend reading a book on OO.
gladiatron wrote: Now, do we have a way to modify this to work
Going from form2 to form1, you should use delegates.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hey Chris and Rahul.....thannx a lot ..constructor technique worked .....but is there any other way to do it?
|
|
|
|
|
|
obviously when you create any object instance, it allocate new empty memory. So just do one thing in form1 click event.create form2 instance, after then assign grid cell in form1 to form2 public property.Now in form2 load event assign that property to each textbox of form2.Now show form2.
Regards
Chintan
www.visharadsoft.com
(Nothing is so purify as KNOWLEDGE)
|
|
|
|
|
Hi.
I have written a code which will prevent multiple instance of a exe to be executed.the code which i wrote is as below
if (processes.Length != 1)
Application.Run(new FormCacheProcessor());
else
MessageBox.Show("Already An Instance of CacheManager Application is Running");
but now i want instead of this message box being poped up, i want already running instance of exe to come to the foreground..i have used SetForegroundWindow but its not working..
Can any pls help me in working it..
Thanks in advance.
Regards
DilipRam
|
|
|
|
|
Rather than rolling your own code to manage this, why not use what .Net 2 provides for you? This[^] set of pages tells you all you need to know on how to do it.
|
|
|
|
|
Hi thanks for the reply..i went through the page you provided but i got confused...have any one work on that specific problem.i just want to activate the already running exe to foreground...
thanks
Regards
DilipRam
|
|
|
|
|
How do I do a mouse over on a GIF picture? I want to get X and Y position on the gif I display over the form. Currently I can only see the mouseover pos on the form surface only not on the picture how do I do the opposite?
Thanks
Samuel
|
|
|
|
|
Hello,
Is this picture in a pictureBox?
If yes, you would have to handle MouseMove there!
All the best,
Martin
|
|
|
|
|
I am sorry, I dont know how to handle mousemove there? and yes its in a picture box. Do you have an example of how I can do this??
Thanks
Samuel
|
|
|
|
|
Hello,
this.pictureBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseMove);
private void pictureBox1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
string actmouseposition= "X: " + e.X + "; Y: " + e.Y;
}
Hope it helps!
All the best,
Martin
|
|
|
|
|
Yes! it works like a charm! Thanks lots!
Thanks
Samuel
|
|
|
|