|
Hi,
I have a ListView in details view and I would like to prevent the user to resize the column widths.
Thanks in advance.
|
|
|
|
|
does it have a ColumnWidthChanging event? and would that support canceling?
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Yes it has and supports canceling but user can change the width even it's canceled. Just the resizing animation isn't shown.
|
|
|
|
|
SimpleData wrote: Yes it has and supports canceling but user can change the width even it's canceled. Just the resizing animation isn't shown.
You can use the ColumnWidthChanging [^]event of the listview.
But surprisingly, it seems to have a bug which MS has accepted. You can have a look here[^].
A possible workaround would be to cancel the event, and set the old width again. (kinda dirty...)
private void listView1_ColumnWidthChanging(object sender, ColumnWidthChangingEventArgs e)
{
e.NewWidth = this.listView1.Columns[e.ColumnIndex].Width;
e.Cancel = true;
}
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
The trick is to also set the NewWidth property to the existing Width :
private void listView_ColumnWidthChanging(object sender, ColumnWidthChangingEventArgs e)
{
e.NewWidth = listView.Columns[e.ColumnIndex].Width;
e.Cancel = true;
} [Edit] Manas posted whilst I was posting! [/Edit]
|
|
|
|
|
Thank you all. Workaround works like a charm.
|
|
|
|
|
|
and the question is?
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Very sorry guys, I thought I'm in the lounge
|
|
|
|
|
Nice but should be in Lounge
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Very sorry guys, I thought I'm in the lounge
|
|
|
|
|
Hi
In my project I have serial port communication..
which will receive three values with an interval of one sec, i want to store it in one single array, i don't know how to do it...
the values are
A0109000000000000i000(1 sec delay) B0109000000000000i000(1 sec delay) C0109000000000000i000
string res= new string[];
the value of res shld be
res=A0109000000000000i000B0109000000000000i000C0109000000000000i000
how to do this
Pls help me
|
|
|
|
|
hi guy,
if you only want to appent the string than you should use a System.Text.StringBuilder strBuilder.Appent(string);
to get the hole string use strBuilder.ToString()...
otherwise declare a generic array of type string, use the System.Collection.Generic.List<string> lst.Add(string);
after all values added copy the generic array to the string array
string res = new string[lst.count];
lst.CopyTo(res);
lst.Clear()
hope i could help!
greetz
|
|
|
|
|
Mads115 wrote: string res= new string[];
that does not compile. You declare a single value and instantiate an array.
Mads115 wrote: res=A0109000000000000i000B0109000000000000i000C0109000000000000i000
whereas this suggests a single string, not an array.
There are several ways to get your data, all assuming you use SerialPort class:
1.
with DataReceived event: read the available data and add it to a List<string>
when three elements are available, remove them from the list and join them together, possibly using string.Join
2.
with DataReceived event: if you're sure about the delays, then include a Thread.Sleep(2500) and read all available data, it will hold the three values (as the next two came in during the sleep).
3.
without DataReceived event: issue a blocking read for the right amount of data.
I would go for (1) as that is the cleanest approach.
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Mads115 wrote: In my project I have serial port communication.
Mads115 wrote: string res= new string[];
You are going to have a tough time.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
I don't see why you'd want all three values in one string. A string array or a List would be a straightforward technique. Or you may want to define a class or structure to hold the values. It depends on what you plan to do with the values afterward.
|
|
|
|
|
I have a datagridview in which two clolumns are of combobox type.In one column i have country names in it.In second column i want the states names country to the country selected.
In this the problem is that when country name is changed in row n+1,the nth row value is also changing.
Please anyone can solve me this issue.
|
|
|
|
|
Its not possible unless you code in that way or I may not got your question.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
How are you binding the comboboxes? Can you post the code?
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
private System.Windows.Forms.DataGridView jobSheetDGV;
private SABDBDataSet6 sABDBCountryDataSet;
private System.Windows.Forms.BindingSource countrytDetailsBindingSource;
private SAB.SABDBDataSet6TableAdapters.CountryDetailsTableAdapter countryDetailsTableAdapter;
private void jobSheetDGV_CellLeave(object sender, DataGridViewCellEventArgs e)
{
int rowIndex = jobSheetDGV.CurrentCell.RowIndex;
if (e.ColumnIndex == 3)
{
if (jobSheetDGV.Rows[rowIndex ].Cells[3].Value == null)
{
string sql2 = "GetCountryIdByCountryName";
DbCommand cmd2 = _db.GetStoredProcCommand(sql2);
_db.AddInParameter(cmd2, "CountryName", DbType.String, jobSheetDGV.Rows[rowIndex].Cells[2].Value);
using (IDataReader dataReader1 = _db.ExecuteReader(cmd2))
{
while (dataReader1.Read())
{
string sql = "GetStatesByCountryId";
DbCommand cmd = _db.GetStoredProcCommand(sql);
_db.AddInParameter(cmd, "CountryId", DbType.Int32, countryId.CountryId);
using (IDataReader dataReader = _db.ExecuteReader(cmd))
{
while (dataReader.Read())
{
states = new States(dataReader.GetInt32(0), dataReader.GetString(1), dataReader.GetString(2), dataReader.GetString(3),
dataReader.GetString(4), dataReader.GetInt32(5));
if (states != null)
States.Items.Add(states);
}
}
}
}
In this States is the column name.
The question is simple that i want to fill states in respective to the country selected.I have a country table with country id as primary key and a state table with country id as foreign key..
}
}
}
|
|
|
|
|
Hi ,
I am Srikrishna Murthy.
I want to implement MVC architecture in a windows application.My application should have Model-View-Controller.While designing the application I am not very clear about how to make calls from the controller to the downlayers.How we can achieve this one.I hope we will have some interfaces and we have to implement them.But,I am not exactly sure how to do this.
My scenario:
Say for example,
1)I have a windows form with two text boxes and 4 buttons for ADD,SUB,MUL,DIV
2)so,when user clicks on any button,from here the data goes to controller.
3)From the controller,How to pass the data to the downlayers.
Please help me .Thanks Inadvance.
Thanks,
M.Srikrishna Murthy
|
|
|
|
|
Why do you want to use MVC ? What problems do you expect it to solve ? I've done winforms apps that used MVC, mostly because I used custom controllers ,and I expected that being able to plug different controller classes into my architecture would meet a specific need, which it did. I've never used it since, as there's never been a situation where it made sense to do so. In that case, I simply used delegates to pass messages between my controller and my model, and between my model and my view.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi christian Graus,
Actually I want to make a desktop application in MVC architecture.
And in that application,Keeping the controller and Model constant ,I want to change the View .i.e
I want to able to communicate with the controller from a Windows Form,A Console Application and also a Web Page.And I want to know exactly how this layering can be done.
Please help me.Thanks Inadvance.
M.Srikrishna Murthy
|
|
|
|
|
Well, the other key component is that I used interfaces, so that I could use any class as the view, for example, so long as it implimented my interface, which then meant that the controller used the class by casting it to an instance of that interface.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi friends
I am new to this C# developement, right now i am working with VB.
Can you give me some links to switch over from VB to C#
Thanks in advance
|
|
|
|